当前位置: 首页>>代码示例>>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;未经允许,请勿转载。