Ejemplo n.º 1
0
 /**
  * Registers a JS file.
  * @param string $url the JS file to be registered.
  * @param array $options the HTML attributes for the script tag. A special option
  *                        named "position" is supported which specifies where the JS script tag should be inserted
  *                        in a page. The possible values of "position" are:
  *
  * - `POS_HEAD`: in the head section
  * - `POS_BEGIN`: at the beginning of the body section
  * - `POS_END`: at the end of the body section. This is the default value.
  *
  * @param string $key the key that identifies the JS script file. If null, it will use
  *                        $url as the key. If two JS files are registered with the same key, the latter
  *                        will overwrite the former.
  */
 public function registerJsFile($url, $options = [], $key = null)
 {
     $key = $key ?: $url;
     if (is_array($key)) {
         $key = current($key);
     }
     $position = isset($options['position']) ? $options['position'] : self::POS_END;
     unset($options['position']);
     $this->jsFiles[$position][$key] = $this->renderWrapperTag(Html::jsFile($url, $options), $options);
 }