yii\web\View::getAssetManager PHP Method

getAssetManager() public method

Registers the asset manager being used by this view object.
public getAssetManager ( ) : AssetManager
return AssetManager the asset manager. Defaults to the "assetManager" application component.
    public function getAssetManager()
    {
        return $this->_assetManager ?: Yii::$app->getAssetManager();
    }

Usage Example

Example #1
4
 /**
  * Adds an asset to the view
  *
  * @param View   $view The View object
  * @param string $file The asset file name
  * @param string $type The asset file type (css or js)
  * @param string $class The class name of the AssetBundle
  *
  * @return void
  */
 protected function addAsset($view, $file, $type, $class)
 {
     if ($type == 'css' || $type == 'js') {
         $asset = $view->getAssetManager();
         $bundle = $asset->bundles[$class];
         if ($type == 'css') {
             $bundle->css[] = $file;
         } else {
             $bundle->js[] = $file;
         }
         $asset->bundles[$class] = $bundle;
         $view->setAssetManager($asset);
     }
 }
All Usage Examples Of yii\web\View::getAssetManager