本文整理汇总了PHP中yii\web\AssetBundle::publish方法的典型用法代码示例。如果您正苦于以下问题:PHP AssetBundle::publish方法的具体用法?PHP AssetBundle::publish怎么用?PHP AssetBundle::publish使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\web\AssetBundle
的用法示例。
在下文中一共展示了AssetBundle::publish方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: publish
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' });");
}
示例2: publish
/**
* @inheritdoc
*/
public function publish($am)
{
parent::publish($am);
$js = <<<JS
emojione.imagePathPNG = '{$this->baseUrl}/assets/png/';
JS;
\Yii::$app->view->registerJs($js);
}
示例3: initView
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;
}
示例4: publish
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);
}
示例5: publish
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
);
}
示例6: publish
/**
* @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);
}
示例7: publish
/**
* 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;
}
示例8: publish
public function publish($am)
{
$this->configureFromClass();
return parent::publish($am);
}
示例9: publish
public function publish($am)
{
parent::publish($am);
$this->css = $this->addLastModifiedParam($this->css);
$this->js = $this->addLastModifiedParam($this->js);
}