コード例 #1
0
ファイル: JsQueue.php プロジェクト: linhntaim/katniss
 public function flush($echo = true)
 {
     $this->output = [];
     foreach ($this->queue as $name => $item) {
         switch ($item['type']) {
             case self::TYPE_RAW:
                 $this->output[] = Html5::jsInline($item['content']);
                 break;
             case self::TYPE_VAR:
                 $content = [];
                 foreach ($item['content'] as $varName => $varValue) {
                     $content[] = 'var ' . $varName . ' = ' . $this->getVarValue($varValue) . ';';
                 }
                 $this->output[] = Html5::jsInline(implode(PHP_EOL, $content));
                 break;
             default:
                 $this->output[] = Html5::js($item['content']);
                 break;
         }
     }
     return parent::flush($echo);
 }