publish() public method

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 ( AssetManager $am )
$am AssetManager the asset manager to perform the asset publishing
コード例 #1
0
 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
0
    /**
     * @inheritdoc
     */
    public function publish($am)
    {
        parent::publish($am);
        $js = <<<JS
    emojione.imagePathPNG = '{$this->baseUrl}/assets/png/';
JS;
        \Yii::$app->view->registerJs($js);
    }
コード例 #3
0
 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
0
 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
0
ファイル: Asset.php プロジェクト: vitprog/yii2-wamp-server
    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
0
 /**
  * @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
0
ファイル: AssetBundle.php プロジェクト: alex-dwt/file
 /**
  * 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
0
ファイル: AssetBundle.php プロジェクト: execut/yii2-base
 public function publish($am)
 {
     $this->configureFromClass();
     return parent::publish($am);
 }
コード例 #9
0
ファイル: AppAsset.php プロジェクト: vsguts/crm
 public function publish($am)
 {
     parent::publish($am);
     $this->css = $this->addLastModifiedParam($this->css);
     $this->js = $this->addLastModifiedParam($this->js);
 }