コード例 #1
0
ファイル: View.php プロジェクト: smallmirror62/framework
 /**
  * Registers a CSS file.
  * @param string $url the CSS file to be registered.
  * @param array $options the HTML attributes for the link tag. Please refer to [[Html::cssFile()]] for
  * the supported options. The following options are specially handled and are not treated as HTML attributes:
  *
  * - `depends`: array, specifies the names of the asset bundles that this CSS file depends on.
  *
  * @param string $key the key that identifies the CSS script file. If null, it will use
  * $url as the key. If two CSS files are registered with the same key, the latter
  * will overwrite the former.
  */
 public function registerCssFile($url, $options = [], $key = null)
 {
     $url = Leaps::getAlias($url);
     $key = $key ?: $url;
     $depends = ArrayHelper::remove($options, 'depends', []);
     if (empty($depends)) {
         $this->cssFiles[$key] = Html::cssFile($url, $options);
     } else {
         $this->getAssetManager()->bundles[$key] = new AssetBundle(['baseUrl' => '', 'css' => [strncmp($url, '//', 2) === 0 ? $url : ltrim($url, '/')], 'cssOptions' => $options, 'depends' => (array) $depends]);
         $this->registerAssetBundle($key);
     }
 }