當前位置: 首頁>>代碼示例>>PHP>>正文


PHP View::getAssetManager方法代碼示例

本文整理匯總了PHP中yii\web\View::getAssetManager方法的典型用法代碼示例。如果您正苦於以下問題:PHP View::getAssetManager方法的具體用法?PHP View::getAssetManager怎麽用?PHP View::getAssetManager使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在yii\web\View的用法示例。


在下文中一共展示了View::getAssetManager方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: addAsset

 /**
  * 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);
     }
 }
開發者ID:slavam,項目名稱:placement,代碼行數:24,代碼來源:WidgetTrait.php

示例2: registerAssetFiles

 /**
  * 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);
 }
開發者ID:hauntd,項目名稱:yii2-basketjs-asset,代碼行數:17,代碼來源:BasketAssetBundle.php

示例3: registerLocaleInternal

 /**
  * @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');
     }
 }
開發者ID:madand,項目名稱:yii2-momentjs,代碼行數:17,代碼來源:MomentJsLocaleAsset.php

示例4: registerLocaleInternal

 /**
  * @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');
     }
 }
開發者ID:servocoder,項目名稱:yii2-momentjs,代碼行數:18,代碼來源:MomentJsLocaleAsset.php

示例5: registerAssetFiles

 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);
     }
 }
開發者ID:phpsong,項目名稱:ExtJS5-Yii2,代碼行數:16,代碼來源:AppAsset.php

示例6: registerAssetFiles

 /**
  * 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);
     }
 }
開發者ID:snivs,項目名稱:semanti,代碼行數:22,代碼來源:AssetBundle.php

示例7: registerAssetFiles

 /**
  * 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);
         }
     }
 }
開發者ID:sadiqhirani,項目名稱:yii2,代碼行數:26,代碼來源:AssetBundle.php

示例8: registerAssetFiles

 /**
  * 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);
     }
 }
開發者ID:maildownload1985,項目名稱:codeCenterA,代碼行數:14,代碼來源:AssetBundle.php


注:本文中的yii\web\View::getAssetManager方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。