示例#1
0
 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);
     }
 }