/** * Loading the ExtJs library and CSS in a view */ public function loadLibrary() { $lib = rtrim($this->config['library_path'], '/') . '/'; foreach (array_reverse($this->config['css']) as $css) { $this->headLink->prependStylesheet($lib . $css); } foreach (array_reverse($this->config['js']) as $js) { $this->headScript->prependFile($lib . $js); } }
/** * @param ScriptContainer $container * @param string|number $place * @return callable */ protected function getInjector($container, $place) { $insert = null; switch ($place) { case self::PLACE_APPEND: $insert = function ($jsFile, $type, $attrs) use($container) { $container->appendFile($jsFile, $type, $attrs); }; break; case self::PLACE_PREPEND: $insert = function ($jsFile, $type, $attrs) use($container) { $container->prependFile($jsFile, $type, $attrs); }; break; default: if (is_numeric($place)) { $insert = function ($jsFile, $type, $attrs) use($container, &$place) { $container->offsetSetFile($place, $jsFile, $type, $attrs); $place++; }; } break; } if (!is_callable($insert)) { throw new \RuntimeException('Failed to make JS files injector.'); } return $insert; }