Final Class Yiisoft\Assets\AssetRegistrar
| Inheritance | Yiisoft\Assets\AssetRegistrar |
|---|
AssetRegistrar registers asset files, code blocks and variables from a bundle considering dependencies.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\Assets\AssetRegistrar | |
| getCssFiles() | Yiisoft\Assets\AssetRegistrar | |
| getCssStrings() | Yiisoft\Assets\AssetRegistrar | |
| getJsFiles() | Yiisoft\Assets\AssetRegistrar | |
| getJsStrings() | Yiisoft\Assets\AssetRegistrar | |
| getJsVars() | Yiisoft\Assets\AssetRegistrar | |
| register() | Registers assets from a bundle considering dependencies. | Yiisoft\Assets\AssetRegistrar |
| withConverter() | Yiisoft\Assets\AssetRegistrar | |
| withLoader() | Yiisoft\Assets\AssetRegistrar |
Method Details
| public mixed __construct ( \Yiisoft\Aliases\Aliases $aliases, Yiisoft\Assets\AssetLoaderInterface $loader ) | ||
| $aliases | \Yiisoft\Aliases\Aliases | |
| $loader | Yiisoft\Assets\AssetLoaderInterface | |
public function __construct(
private Aliases $aliases,
private AssetLoaderInterface $loader
) {
}
| public array getCssFiles ( ) | ||
| return | array |
Config array of CSS files. |
|---|---|---|
public function getCssFiles(): array
{
return $this->cssFiles;
}
| public array getCssStrings ( ) | ||
| return | array |
CSS blocks. |
|---|---|---|
public function getCssStrings(): array
{
return $this->cssStrings;
}
| public array getJsFiles ( ) | ||
| return | array |
Config array of JavaScript files. |
|---|---|---|
public function getJsFiles(): array
{
return $this->jsFiles;
}
| public array getJsStrings ( ) | ||
| return | array |
JavaScript code blocks. |
|---|---|---|
public function getJsStrings(): array
{
return $this->jsStrings;
}
| public array getJsVars ( ) | ||
| return | array |
JavaScript variables. |
|---|---|---|
public function getJsVars(): array
{
return array_values($this->jsVars);
}
Registers assets from a bundle considering dependencies.
| public void register ( Yiisoft\Assets\AssetBundle $bundle ) | ||
| $bundle | Yiisoft\Assets\AssetBundle | |
| throws | Yiisoft\Assets\Exception\InvalidConfigException |
If asset files are not found. |
|---|---|---|
public function register(AssetBundle $bundle): void
{
if (isset($bundle->basePath, $bundle->baseUrl) && $this->converter !== null) {
$this->convertCss($bundle);
$this->convertJs($bundle);
}
/** @var JsFile|string $js */
foreach ($bundle->js as $key => $js) {
$this->registerJsFile(
$bundle,
is_string($key) ? $key : null,
$js,
);
}
foreach ($bundle->jsStrings as $key => $jsString) {
$this->registerJsString(
$bundle,
is_string($key) ? $key : null,
$jsString,
);
}
/** @var JsVar|string $jsVar */
foreach ($bundle->jsVars as $name => $jsVar) {
if (is_string($name)) {
$this->registerJsVar($name, $jsVar, $bundle->jsPosition);
} else {
$this->registerJsVarByConfig($jsVar, $bundle->jsPosition);
}
}
/** @var CssFile|string $css */
foreach ($bundle->css as $key => $css) {
$this->registerCssFile(
$bundle,
is_string($key) ? $key : null,
$css,
);
}
foreach ($bundle->cssStrings as $key => $cssString) {
$this->registerCssString(
$bundle,
is_string($key) ? $key : null,
$cssString,
);
}
}
| public self withConverter ( Yiisoft\Assets\AssetConverterInterface $converter ) | ||
| $converter | Yiisoft\Assets\AssetConverterInterface | |
| return | self |
A new instance with the specified converter. |
|---|---|---|
public function withConverter(AssetConverterInterface $converter): self
{
$new = clone $this;
$new->converter = $converter;
return $new;
}
| public self withLoader ( Yiisoft\Assets\AssetLoaderInterface $loader ) | ||
| $loader | Yiisoft\Assets\AssetLoaderInterface | |
| return | self |
A new instance with the specified loader. |
|---|---|---|
public function withLoader(AssetLoaderInterface $loader): self
{
$new = clone $this;
$new->loader = $loader;
return $new;
}
Signup or Login in order to comment.