本文整理汇总了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);
}
}
示例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);
}
示例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');
}
}
示例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');
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
}
示例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);
}
}