0 フォロワー

クラス yii\widgets\PjaxAsset

継承yii\widgets\PjaxAsset » yii\web\AssetBundle » yii\base\BaseObject
実装yii\base\Configurable
利用可能バージョン2.0
ソースコード https://github.com/yiisoft/yii2/blob/master/framework/widgets/PjaxAsset.php

このアセットバンドルは、yii\widgets\Pjax ウィジェットに必要なJavaScriptファイルを提供します。

公開プロパティ

継承されたプロパティを隠す

プロパティ 説明 定義元
$basePath string このバンドル内のアセットファイルを含む、Webからアクセス可能なディレクトリ。 yii\web\AssetBundle
$baseUrl string $js$css にリストされている相対アセットファイルのベースURL。 yii\web\AssetBundle
$css array このバンドルに含まれるCSSファイルのリスト。 yii\web\AssetBundle
$cssOptions array このバンドル内のCSSファイルを登録する際に、yii\web\View::registerCssFile() に渡されるオプション。 yii\web\AssetBundle
$depends yii\widgets\PjaxAsset
$js yii\widgets\PjaxAsset
$jsOptions array このバンドル内のJSファイルを登録する際に、yii\web\View::registerJsFile() に渡されるオプション。 yii\web\AssetBundle
$publishOptions array アセットバンドルが公開される際に、yii\web\AssetManager::publish() に渡されるオプション。 yii\web\AssetBundle
$sourcePath yii\widgets\PjaxAsset

公開メソッド

継承されたメソッドを隠す

メソッド 説明 定義元
__call() クラスメソッドではない、指定されたメソッドを呼び出します。 yii\base\BaseObject
__construct() コンストラクタ。 yii\base\BaseObject
__get() オブジェクトのプロパティの値を返します。 yii\base\BaseObject
__isset() プロパティが設定されているかどうか(定義されていてnullでないか)をチェックします。 yii\base\BaseObject
__set() オブジェクトのプロパティの値を設定します。 yii\base\BaseObject
__unset() オブジェクトのプロパティをnullに設定します。 yii\base\BaseObject
canGetProperty() プロパティを読み取ることができるかどうかを示す値を返します。 yii\base\BaseObject
canSetProperty() プロパティを設定できるかどうかを示す値を返します。 yii\base\BaseObject
className() このクラスの完全修飾名を返します。 yii\base\BaseObject
hasMethod() メソッドが定義されているかどうかを示す値を返します。 yii\base\BaseObject
hasProperty() プロパティが定義されているかどうかを示す値を返します。 yii\base\BaseObject
init() バンドルを初期化します。 yii\web\AssetBundle
publish() ソースコードがWebからアクセス可能なディレクトリにない場合、アセットバンドルを公開します。 yii\web\AssetBundle
register() ビューにこのアセットバンドルを登録します。 yii\web\AssetBundle
registerAssetFiles() 指定されたビューにCSSとJSファイルを登録します。 yii\web\AssetBundle

プロパティの詳細

継承されたプロパティを隠す

$depends public property
public $depends = [
    
'yii\web\YiiAsset',
]
$js public property
public $js = [
    
'jquery.pjax.js',
]
$sourcePath public property
public $sourcePath '@bower/yii2-pjax'

メソッドの詳細

継承されたメソッドを隠す

__call() public method

定義元: yii\base\BaseObject::__call()

クラスメソッドではない、指定されたメソッドを呼び出します。

これはPHPのマジックメソッドであり、未知のメソッドが呼び出された際に暗黙的に呼び出されるため、直接呼び出さないでください。

public mixed __call ( $name, $params )
$name string

メソッド名

$params array

メソッドパラメータ

戻り値 mixed

メソッドの戻り値

例外 yii\base\UnknownMethodException

未知のメソッドを呼び出した場合

                public function __call($name, $params)
{
    throw new UnknownMethodException('Calling unknown method: ' . get_class($this) . "::$name()");
}

            
__construct() public method

定義元: yii\base\BaseObject::__construct()

コンストラクタ。

デフォルトの実装は次の2つのことを行います。

  • 指定された設定$configを使用してオブジェクトを初期化します。
  • init() を呼び出します。

このメソッドを子クラスでオーバーライドする場合は、

  • コンストラクタの最後の引数を設定配列(ここでは$config)にすることをお勧めします。
  • コンストラクタの最後に親の実装を呼び出してください。
public void __construct ( $config = [] )
$config array

オブジェクトのプロパティを初期化するのに使用される、名前と値のペア

                public function __construct($config = [])
{
    if (!empty($config)) {
        Yii::configure($this, $config);
    }
    $this->init();
}

            
__get() publicメソッド

定義位置: yii\base\BaseObject::__get()

オブジェクトのプロパティの値を返します。

これはPHPのマジックメソッドであり、`$value = $object->property;` を実行した際に暗黙的に呼び出されるため、直接呼び出さないでください。

参照: __set().

public mixed __get ( $name )
$name string

プロパティ名

戻り値 mixed

プロパティ値

例外 yii\base\UnknownPropertyException

プロパティが定義されていない場合

例外 yii\base\InvalidCallException

プロパティが書き込み専用の場合

                public function __get($name)
{
    $getter = 'get' . $name;
    if (method_exists($this, $getter)) {
        return $this->$getter();
    } elseif (method_exists($this, 'set' . $name)) {
        throw new InvalidCallException('Getting write-only property: ' . get_class($this) . '::' . $name);
    }
    throw new UnknownPropertyException('Getting unknown property: ' . get_class($this) . '::' . $name);
}

            
__isset() publicメソッド

定義位置: yii\base\BaseObject::__isset()

プロパティが設定されているかどうか(定義されていてnullでないか)をチェックします。

これはPHPのマジックメソッドであり、`isset($object->property)` を実行した際に暗黙的に呼び出されるため、直接呼び出さないでください。

プロパティが定義されていない場合、falseが返されることに注意してください。

参照: https://www.php.net/manual/en/function.isset.php.

public boolean __isset ( $name )
$name string

プロパティ名またはイベント名

戻り値 boolean

指定されたプロパティが設定されているかどうか(nullでないか)。

                public function __isset($name)
{
    $getter = 'get' . $name;
    if (method_exists($this, $getter)) {
        return $this->$getter() !== null;
    }
    return false;
}

            
__set() publicメソッド

定義位置: yii\base\BaseObject::__set()

オブジェクトのプロパティの値を設定します。

これはPHPのマジックメソッドであり、`$object->property = $value;` を実行した際に暗黙的に呼び出されるため、直接呼び出さないでください。

参照: __get().

public void __set ( $name, $value )
$name string

プロパティ名またはイベント名

$value mixed

プロパティ値

例外 yii\base\UnknownPropertyException

プロパティが定義されていない場合

例外 yii\base\InvalidCallException

プロパティが読み取り専用の場合

                public function __set($name, $value)
{
    $setter = 'set' . $name;
    if (method_exists($this, $setter)) {
        $this->$setter($value);
    } elseif (method_exists($this, 'get' . $name)) {
        throw new InvalidCallException('Setting read-only property: ' . get_class($this) . '::' . $name);
    } else {
        throw new UnknownPropertyException('Setting unknown property: ' . get_class($this) . '::' . $name);
    }
}

            
__unset() publicメソッド

定義位置: yii\base\BaseObject::__unset()

オブジェクトのプロパティをnullに設定します。

これはPHPのマジックメソッドであり、`unset($object->property)` を実行した際に暗黙的に呼び出されるため、直接呼び出さないでください。

プロパティが定義されていない場合、このメソッドは何もしません。プロパティが読み取り専用の場合、例外をスローします。

参照: https://www.php.net/manual/en/function.unset.php.

public void __unset ( $name )
$name string

プロパティ名

例外 yii\base\InvalidCallException

プロパティが読み取り専用の場合。

                public function __unset($name)
{
    $setter = 'set' . $name;
    if (method_exists($this, $setter)) {
        $this->$setter(null);
    } elseif (method_exists($this, 'get' . $name)) {
        throw new InvalidCallException('Unsetting read-only property: ' . get_class($this) . '::' . $name);
    }
}

            
canGetProperty() publicメソッド

定義位置: yii\base\BaseObject::canGetProperty()

プロパティを読み取ることができるかどうかを示す値を返します。

プロパティは、以下の場合に読み取り可能です。

  • クラスが、指定された名前に関連付けられたゲッターメソッドを持つ場合(この場合、プロパティ名はケースインセンシティブです)。
  • クラスが、指定された名前のメンバ変数を持つ場合(`$checkVars` がtrueの場合)。

参照: canSetProperty().

public boolean canGetProperty ( $name, $checkVars true )
$name string

プロパティ名

$checkVars boolean

メンバ変数をプロパティとして扱うかどうか

戻り値 boolean

プロパティを読み取ることができるかどうか

                public function canGetProperty($name, $checkVars = true)
{
    return method_exists($this, 'get' . $name) || $checkVars && property_exists($this, $name);
}

            
canSetProperty() publicメソッド

定義位置: yii\base\BaseObject::canSetProperty()

プロパティを設定できるかどうかを示す値を返します。

プロパティは、以下の場合に書き込み可能です。

  • クラスが、指定された名前に関連付けられたセッターメソッドを持つ場合(この場合、プロパティ名はケースインセンシティブです)。
  • クラスが、指定された名前のメンバ変数を持つ場合(`$checkVars` がtrueの場合)。

参照: canGetProperty().

public boolean canSetProperty ( $name, $checkVars true )
$name string

プロパティ名

$checkVars boolean

メンバ変数をプロパティとして扱うかどうか

戻り値 boolean

プロパティを書き込めるかどうか

                public function canSetProperty($name, $checkVars = true)
{
    return method_exists($this, 'set' . $name) || $checkVars && property_exists($this, $name);
}

            
className() public staticメソッド
2.0.14以降非推奨。PHP >= 5.5では、代わりに`::class`を使用してください。

定義位置: yii\base\BaseObject::className()

このクラスの完全修飾名を返します。

public static string className ( )
戻り値 string

このクラスの完全修飾名。

                public static function className()
{
    return get_called_class();
}

            
hasMethod() publicメソッド

定義位置: yii\base\BaseObject::hasMethod()

メソッドが定義されているかどうかを示す値を返します。

デフォルトの実装は、PHP関数`method_exists()`の呼び出しです。PHPマジックメソッド`__call()`を実装した場合は、このメソッドをオーバーライドできます。

public boolean hasMethod ( $name )
$name string

メソッド名

戻り値 boolean

メソッドが定義されているかどうか

                public function hasMethod($name)
{
    return method_exists($this, $name);
}

            
hasProperty() publicメソッド

定義位置: yii\base\BaseObject::hasProperty()

プロパティが定義されているかどうかを示す値を返します。

プロパティは、以下の場合に定義されています。

  • クラスが、指定された名前に関連付けられたゲッターまたはセッターメソッドを持つ場合(この場合、プロパティ名はケースインセンシティブです)。
  • クラスが、指定された名前のメンバ変数を持つ場合(`$checkVars` がtrueの場合)。

参照:

public boolean hasProperty ( $name, $checkVars true )
$name string

プロパティ名

$checkVars boolean

メンバ変数をプロパティとして扱うかどうか

戻り値 boolean

プロパティが定義されているかどうか

                public function hasProperty($name, $checkVars = true)
{
    return $this->canGetProperty($name, $checkVars) || $this->canSetProperty($name, false);
}

            
init() publicメソッド

定義位置: yii\web\AssetBundle::init()

バンドルを初期化します。

このメソッドをオーバーライドする場合は、最後に親の実装を呼び出すようにしてください。

public void init ( )

                public function init()
{
    if ($this->sourcePath !== null) {
        $this->sourcePath = rtrim(Yii::getAlias($this->sourcePath), '/\\');
    }
    if ($this->basePath !== null) {
        $this->basePath = rtrim(Yii::getAlias($this->basePath), '/\\');
    }
    if ($this->baseUrl !== null) {
        $this->baseUrl = rtrim(Yii::getAlias($this->baseUrl), '/');
    }
}

            
publish() publicメソッド

定義位置: yii\web\AssetBundle::publish()

ソースコードがWebからアクセス可能なディレクトリにない場合、アセットバンドルを公開します。

また、アセットコンバーターを使用して、CSSまたはJSファイル以外のファイル(例:LESS、Sass)を対応するCSSまたはJSファイルに変換しようとします。

public void publish ( $am )
$am yii\web\AssetManager

アセットの公開を実行するアセットマネージャー

                public function publish($am)
{
    if ($this->sourcePath !== null && !isset($this->basePath, $this->baseUrl)) {
        list($this->basePath, $this->baseUrl) = $am->publish($this->sourcePath, $this->publishOptions);
    }
    if (isset($this->basePath, $this->baseUrl) && ($converter = $am->getConverter()) !== null) {
        foreach ($this->js as $i => $js) {
            if (is_array($js)) {
                $file = array_shift($js);
                if (Url::isRelative($file)) {
                    $js = ArrayHelper::merge($this->jsOptions, $js);
                    array_unshift($js, $converter->convert($file, $this->basePath));
                    $this->js[$i] = $js;
                }
            } elseif (Url::isRelative($js)) {
                $this->js[$i] = $converter->convert($js, $this->basePath);
            }
        }
        foreach ($this->css as $i => $css) {
            if (is_array($css)) {
                $file = array_shift($css);
                if (Url::isRelative($file)) {
                    $css = ArrayHelper::merge($this->cssOptions, $css);
                    array_unshift($css, $converter->convert($file, $this->basePath));
                    $this->css[$i] = $css;
                }
            } elseif (Url::isRelative($css)) {
                $this->css[$i] = $converter->convert($css, $this->basePath);
            }
        }
    }
}

            
register() public static メソッド

定義されている場所: yii\web\AssetBundle::register()

ビューにこのアセットバンドルを登録します。

public static static register ( $view )
$view yii\web\View

登録先のビュー

戻り値 yii\web\AssetBundle

登録されたアセットバンドルインスタンス

                public static function register($view)
{
    return $view->registerAssetBundle(get_called_class());
}

            
registerAssetFiles() public メソッド

定義されている場所: yii\web\AssetBundle::registerAssetFiles()

指定されたビューにCSSとJSファイルを登録します。

public void registerAssetFiles ( $view )
$view yii\web\View

アセットファイルを登録するビュー。

                public function registerAssetFiles($view)
{
    $manager = $view->getAssetManager();
    foreach ($this->js as $js) {
        if (is_array($js)) {
            $file = array_shift($js);
            $options = ArrayHelper::merge($this->jsOptions, $js);
            $view->registerJsFile($manager->getAssetUrl($this, $file, ArrayHelper::getValue($options, 'appendTimestamp')), $options);
        } elseif ($js !== null) {
            $view->registerJsFile($manager->getAssetUrl($this, $js), $this->jsOptions);
        }
    }
    foreach ($this->css as $css) {
        if (is_array($css)) {
            $file = array_shift($css);
            $options = ArrayHelper::merge($this->cssOptions, $css);
            $view->registerCssFile($manager->getAssetUrl($this, $file, ArrayHelper::getValue($options, 'appendTimestamp')), $options);
        } elseif ($css !== null) {
            $view->registerCssFile($manager->getAssetUrl($this, $css), $this->cssOptions);
        }
    }
}