It will also try to convert non-CSS or JS files (e.g. LESS, Sass) into the corresponding
CSS or JS files using [[AssetManager::converter|asset converter]].
public publish ( |
||
$am | the asset manager to perform the asset publishing |
public function publish($am) { parent::publish($am); $view = Yii::$app->getView(); $language = Yii::$app->language; $view->registerJs("i18n.init({ lng: '{$language}', resGetPath: '/locales/__lng__/__ns__.json', fallbackLng: 'en' });"); }
/** * @inheritdoc */ public function publish($am) { parent::publish($am); $js = <<<JS emojione.imagePathPNG = '{$this->baseUrl}/assets/png/'; JS; \Yii::$app->view->registerJs($js); }
public function initView($view) { $files = [pathinfo('@nitm/assets/js/jquery-plugins/jquery.ui.widget.js'), pathinfo('@nitm/assets/js/jquery-plugins/jquery-ui-scrollable/jquery-ui-scrollable.js')]; foreach ($files as $f) { $asset = new \yii\web\AssetBundle(['sourcePath' => $f['dirname'], 'js' => [$f['basename']]]); $asset->publish($view->getAssetManager()); $view->assetBundles[static::className() . '\\' . $f['basename']] = $asset; } return $this; }
public function publish($assetManager) { $module = \bedezign\yii2\audit\Auditing::current(); if ($module && $module->entry) { // We can't be sure that the actual logger was loaded already, so we fallback on the window object // to store the associated audit entry id \Yii::$app->view->registerJs("window.auditEntry = {$module->entry->id};", \yii\web\View::POS_HEAD); } return parent::publish($assetManager); }
public function publish($am) { parent::publish($am); $jsSettings = ArrayHelper::merge([], static::$jsSettings); if ($jsSettings['uid']) { $jsSettings['uid'] = (int) $jsSettings['uid']; } $jsSettings = Json::encode($jsSettings); \Yii::$app->getView()->registerJs(<<<JS wamp.init({$jsSettings}); JS ); }
/** * @param \yii\web\AssetManager $assetManager */ public function publish($assetManager) { $module = Audit::getInstance(); // We can't be sure that the actual logger was loaded already, so we fallback on the window object // to store the associated audit url and entry id $url = Url::to(["/{$module->id}/js-log"]); $script = "window.auditUrl = '{$url}';"; if ($module->entry) { $id = $module->getEntry()->id; $script .= "window.auditEntry = {$id};"; } \Yii::$app->view->registerJs($script, View::POS_HEAD); parent::publish($assetManager); }
/** * Publishes the asset bundle if its source code is not under Web-accessible directory. * It will also try to convert non-CSS or JS files (e.g. LESS, Sass) into the corresponding * CSS or JS files using [[AssetManager::converter|asset converter]]. * * This method set [[AssetManager::linkAssets]] value to false before publishing * and restore it after. * * @param AssetManager $am the asset manager to perform the asset publishing */ public function publish($am) { if (!count($this->allowedDirectories)) { return parent::publish($am); } $oldLinkAssets = $am->linkAssets; $am->linkAssets = false; try { $this->publishOptions['beforeCopy'] = \Yii::createObject(array('class' => AssetDirectoriesFilter::className(), 'assetManager' => $am, 'assetBundle' => $this)); $result = parent::publish($am); } catch (\Exception $ex) { $am->linkAssets = $oldLinkAssets; throw $ex; } $am->linkAssets = $oldLinkAssets; return $result; }
public function publish($am) { $this->configureFromClass(); return parent::publish($am); }
public function publish($am) { parent::publish($am); $this->css = $this->addLastModifiedParam($this->css); $this->js = $this->addLastModifiedParam($this->js); }