本文整理汇总了PHP中yii\web\AssetBundle::className方法的典型用法代码示例。如果您正苦于以下问题:PHP AssetBundle::className方法的具体用法?PHP AssetBundle::className怎么用?PHP AssetBundle::className使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\web\AssetBundle
的用法示例。
在下文中一共展示了AssetBundle::className方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: registerMonolith
/**
* @param AssetBundle $bundle
*/
public function registerMonolith($bundle)
{
// Remove bundle and its dependencies from list
unset($this->bundles[$bundle->className()]);
if (!empty($bundle->publishOptions['accIncluded'])) {
foreach ($bundle->publishOptions['accIncluded'] as $name) {
if (isset($this->bundles[$name])) {
unset($this->bundles[$name]);
}
}
}
// Register files
foreach ($bundle->js as $filename) {
$this->owner->registerJsFile($bundle->baseUrl . '/' . $filename, $bundle->jsOptions);
}
foreach ($bundle->css as $filename) {
$this->owner->registerCssFile($bundle->baseUrl . '/' . $filename, $bundle->cssOptions);
}
}
示例2: registerJsFile
/**
* Registers a JS file.
* @param string $url the JS file to be registered.
* @param array $options the HTML attributes for the script tag. The following options are specially handled
* and are not treated as HTML attributes:
*
* - `depends`: array, specifies the names of the asset bundles that this JS file depends on.
* - `position`: specifies where the JS script tag should be inserted in a page. The possible values 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.
*
* Please refer to [[Html::jsFile()]] for other supported options.
*
* @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 at the same position, the latter
* will overwrite the former. Note that position option takes precedence, thus files registered with the same key,
* but different position option will not override each other.
*/
public function registerJsFile($url, $options = [], $key = null)
{
$url = Yii::getAlias($url);
$key = $key ?: $url;
$depends = ArrayHelper::remove($options, 'depends', []);
if (empty($depends)) {
$position = ArrayHelper::remove($options, 'position', self::POS_END);
$this->jsFiles[$position][$key] = Html::jsFile($url, $options);
} else {
$this->getAssetManager()->bundles[$key] = Yii::createObject(['class' => AssetBundle::className(), 'baseUrl' => '', 'js' => [strncmp($url, '//', 2) === 0 ? $url : ltrim($url, '/')], 'jsOptions' => $options, 'depends' => (array) $depends]);
$this->registerAssetBundle($key);
}
}
示例3:
<?php
use yii\web\View;
use yii\web\AssetBundle;
?>
<?php
$this->registerJsFile('/js/last/jquery.js', [AssetBundle::className()]);
$this->registerJsFile('/player/video.js', [AssetBundle::className()]);
$this->registerCssFile('/player/video-js.css');
$this->registerJsFile('/player/video-init.js', [View::POS_END]);
?>
<h3>Player</h3
<!--<video id="example_video_1" class="video-js vjs-default-skin" controls preload="none" width="640" height="264"-->
<!-- poster="http://video-js.zencoder.com/oceans-clip.png"-->
<!-- data-setup="{}">-->
<!-- <source src="http://video-js.zencoder.com/oceans-clip.mp4" type='video/mp4' />-->
<!-- <source src="http://video-js.zencoder.com/oceans-clip.webm" type='video/webm' />-->
<!-- <source src="http://video-js.zencoder.com/oceans-clip.ogv" type='video/ogg' />-->
<!-- <track kind="captions" src="demo.captions.vtt" srclang="en" label="English"></track><!-- Tracks need an ending tag thanks to IE9 -->-->
<!-- <track kind="subtitles" src="demo.captions.vtt" srclang="en" label="English"></track><!-- Tracks need an ending tag thanks to IE9 -->-->
<!-- <p class="vjs-no-js">To view this video please enable JavaScript, and consider upgrading to a web browser that <a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a></p>-->
<!--</video>-->
<video id="example_video_2" class="video-js vjs-default-skin"
controls preload="true" width="640" height="480"
<!-- poster="http://video-js.zencoder.com/oceans-clip.png"-->
<!-- data-setup='{"example_option":true}'>-->