Skip to content

Commit

Permalink
Cleanup methods and docBlocks of AssetManager
Browse files Browse the repository at this point in the history
  • Loading branch information
devanych committed Mar 25, 2021
1 parent fe16bf9 commit 7819318
Show file tree
Hide file tree
Showing 10 changed files with 276 additions and 391 deletions.
16 changes: 8 additions & 8 deletions src/AssetBundle.php
Expand Up @@ -7,9 +7,9 @@
/**
* AssetBundle represents a collection of asset files, such as CSS, JS, images.
*
* Each asset bundle has a unique name that globally identifies it among all asset bundles used in an application. The
* name is the [fully qualified class name](http://php.net/manual/en/language.namespaces.rules.php) of the class
* representing it.
* Each asset bundle has a unique name that globally identifies it among all asset bundles used in an application.
* The name is the fully qualified class name {@see https://www.php.net/manual/en/language.namespaces.rules.php}
* of the class representing it.
*
* An asset bundle can depend on other asset bundles. When registering an asset bundle with a view, all its dependent
* asset bundles will be automatically registered.
Expand Down Expand Up @@ -77,15 +77,15 @@ class AssetBundle
];

/**
* @var array List of bundle class names that this bundle depends on.
* @var array List of asset bundle class names that this bundle depends on.
*
* For example:
*
* ```php
* public $depends = [
* \Yiisoft\Jquery\YiiAsset::class,
* \Yiisoft\Bootstrap4\BootstrapAsset::class,
* ];
* public array $depends = [
* Yiisoft\Yii\Bootstrap5\Assets\BootstrapAsset:class,
* Yiisoft\Yii\Bulma\Asset\BulmaAsset:class,
* ]:
* ```
*/
public array $depends = [];
Expand Down
180 changes: 63 additions & 117 deletions src/AssetManager.php

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions src/AssetPublisher.php
Expand Up @@ -71,14 +71,14 @@ final class AssetPublisher implements AssetPublisherInterface
private ?string $baseUrl = null;

/**
* @var array The options that will be passed to {@see \Yiisoft\View\View::registerCssFile()} when registering the
* CSS files all assets bundle.
* @var array The options that will be passed to {@see \Yiisoft\View\WebView::registerCssFile()}
* when registering the CSS files all assets bundle.
*/
private array $cssDefaultOptions = [];

/**
* @var array The options that will be passed to {@see \Yiisoft\View\View::registerJsFile()} when registering the
* JS files all assets bundle.
* @var array The options that will be passed to {@see \Yiisoft\View\WebView::registerJsFile()}
* when registering the JS files all assets bundle.
*/
private array $jsDefaultOptions = [];

Expand Down Expand Up @@ -192,7 +192,7 @@ public function getAssetUrl(AssetBundle $bundle, string $assetPath): string
$url = $this->getBundleBaseUrl($bundle) . '/' . $assetPath;

if (!is_file($path)) {
throw new InvalidConfigException("Asset files not found: '$path'.");
throw new InvalidConfigException("Asset files not found: \"{$path}\".");
}

if ($this->appendTimestamp && ($timestamp = FileHelper::lastModifiedTime("$path")) > 0) {
Expand All @@ -215,12 +215,12 @@ public function getLinkAssets(): bool
/**
* Loads asset bundle class by name.
*
* @param string $name The bundle name.
* @param array $config The bundle object configuration.
* @param string $name The asset bundle name.
* @param array $config The asset bundle instance configuration.
*
* @throws InvalidConfigException
* @throws InvalidConfigException For invalid asset bundle configuration.
*
* @return AssetBundle
* @return AssetBundle The asset bundle instance.
*/
public function loadBundle(string $name, array $config = []): AssetBundle
{
Expand Down Expand Up @@ -292,7 +292,7 @@ public function publish(AssetBundle $bundle): array
$this->checkBundleData($bundle);

if (!file_exists($this->aliases->get($bundle->sourcePath))) {
throw new InvalidConfigException("The sourcePath to be published does not exist: $bundle->sourcePath");
throw new InvalidConfigException("The sourcePath to be published does not exist: {$bundle->sourcePath}");
}

return $this->published[$bundle->sourcePath] = $this->publishBundleDirectory($bundle);
Expand Down
4 changes: 2 additions & 2 deletions src/AssetPublisherInterface.php
Expand Up @@ -29,8 +29,8 @@ public function getAssetUrl(AssetBundle $bundle, string $assetPath): string;
/**
* Loads asset bundle class by name.
*
* @param string $name The bundle name.
* @param array $config The bundle object configuration.
* @param string $name The asset bundle name.
* @param array $config The asset bundle instance configuration.
*
* @throws InvalidConfigException
*
Expand Down

0 comments on commit 7819318

Please sign in to comment.