/** * Registers this asset bundle with a view. * @param View $view the view to be registered with * @return static the registered asset bundle instance */ public function registerAssetFiles($view) { if (\Yii::$app->request->isPjax) { return parent::registerAssetFiles($view); } parent::registerAssetFiles($view); }
public function init() { parent::init(); $this->js = (array) $this->js; if (count($this->js) <= 1) { return; } $fileName = 'yii2-sx-' . md5($this->className()) . ".js"; $fileMinJs = \Yii::getAlias('@app/runtime/assets/js/' . $fileName); if (file_exists($fileMinJs)) { $this->js = [$fileName]; $this->sourcePath = '@app/runtime/assets/js'; return; } $fileContent = ""; foreach ($this->js as $js) { $fileContent .= file_get_contents($this->sourcePath . '/' . $js); } if ($fileContent) { $file = new File($fileMinJs); $file->make($fileContent); } }