Registers the asset manager being used by this view object.
public getAssetManager ( ) : |
||
return | the asset manager. Defaults to the "assetManager" application component. |
/** * 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); } }
/** * Registers the CSS and JS files with the given view. * @param \yii\web\View $view the view that the asset files are to be registered with. */ public function registerAssetFiles($view) { $manager = $view->getAssetManager(); foreach ($this->css as $css) { $view->registerCssFile($manager->getAssetUrl($this, $css), $this->cssOptions); } $view->registerJsFile($this->basketJs); $jsFiles = []; foreach ($this->js as $js) { $jsFiles[] = Json::encode(['url' => $manager->getAssetUrl($this, $js)]); } $view->registerJs(sprintf('basket.require(%s);', implode(",\r\n", $jsFiles)), View::POS_END); }
/** * @param \yii\web\View $view * @throws \yii\base\InvalidConfigException If file with the locale is not exists. */ public function registerLocaleInternal($view) { $localeFilePath = $this->tryFindLocale(); if (YII_DEBUG && !$localeFilePath) { throw new InvalidConfigException('Locale file "' . \Yii::$app->language . '" not exists!'); } $manager = $view->getAssetManager(); $view->registerJsFile($manager->getAssetUrl($this, $this->locale), $this->jsOptions, 'moment-locale-' . $this->locale); if ($this->setLocaleOnReady) { $js = "moment().locale('" . $this->locale . "');"; $view->registerJs($js, View::POS_READY, 'moment-set-default-locale'); } }
/** * @param \yii\web\View $view * @throws \yii\base\InvalidConfigException If file with the locale is not exists. */ public function registerLocaleInternal($view) { $localeFile = strtolower($this->locale) . '.js'; $localeFilePath = "{$this->sourcePath}/{$localeFile}"; if (YII_DEBUG && !file_exists($localeFilePath)) { throw new InvalidConfigException('Locale file "' . $localeFilePath . '" not exists!'); } $manager = $view->getAssetManager(); $view->registerJsFile($manager->getAssetUrl($this, $localeFile), $this->jsOptions, 'moment-locale-' . $this->locale); if ($this->setLocaleOnReady) { $js = "moment.locale('{$this->locale}');'"; $view->registerJs($js, View::POS_READY, 'moment-set-default-locale'); } }
public function registerAssetFiles(View $view) { $manager = $view->getAssetManager(); $arr_js = $this->js; $arr_css = $this->css; if (isset($view->context->layout) && $view->context->layout === 'parts') { $arr_js = $this->js_parts; $arr_css = $this->css_parts; } foreach ($arr_js as $js) { $view->registerJsFile($manager->getAssetUrl($this, $js), $this->jsOptions); } foreach ($arr_css as $css) { $view->registerCssFile($manager->getAssetUrl($this, $css), $this->cssOptions); } }
/** * Registers the CSS and JS files with the given view. * @param \yii\web\View $view the view that the asset files are to be registered with. */ public function registerAssetFiles($view) { $manager = $view->getAssetManager(); foreach ($this->js as $js) { $view->registerJsFile($manager->getAssetUrl($this, $js), $this->jsOptions); } foreach ($this->css as $css) { // FIX ------------------------------------------------------------- // save converted files in to css folder instead of scss $pos = strrpos($css, '.'); $ext = $pos !== false ? substr($css, $pos + 1) : null; if ($ext == 'css') { $css = preg_replace("/^scss\\//i", "css/", $css); } // ----------------------------------------------------------------- $view->registerCssFile($manager->getAssetUrl($this, $css), $this->cssOptions); } }
/** * Registers the CSS and JS files with the given view. * @param \yii\web\View $view the view that the asset files are to be registered with. */ 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), $options); } else { $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), $options); } else { $view->registerCssFile($manager->getAssetUrl($this, $css), $this->cssOptions); } } }
/** * Registers the CSS and JS files with the given view. * @param \yii\web\View $view the view that the asset files are to be registered with. */ public function registerAssetFiles($view) { $manager = $view->getAssetManager(); foreach ($this->js as $js) { $view->registerJsFile($manager->getAssetUrl($this, $js), $this->jsOptions); } foreach ($this->css as $css) { $view->registerCssFile($manager->getAssetUrl($this, $css), $this->cssOptions); } }