Back to WebAssetRegistry class

Method get

public \Joomla\CMS\WebAsset\WebAssetItem
get
(string $type, string $name)
Get an existing Asset from a registry, by asset name.
Parameters
  • string $type Asset type, script or style
  • string $name Asset name
Returns
  • \Joomla\CMS\WebAsset\WebAssetItem
Since
  • 4.0.0
-
  • \Joomla\CMS\WebAsset\Exception\UnknownAssetException When Asset cannot be found

Method get - Source code

/**
 * Get an existing Asset from a registry, by asset name.
 *
 * @param   string  $type  Asset type, script or style
 * @param   string  $name  Asset name
 *
 * @return  WebAssetItem
 *
 * @throws  UnknownAssetException  When Asset cannot be found
 *
 * @since   4.0.0
 */
public function get(string $type, string $name) : WebAssetItemInterface
{
    // Check if any new file was added
    $this->parseRegistryFiles();
    if (empty($this->assets[$type][$name])) {
        throw new UnknownAssetException(sprintf('There is no "%s" asset of a "%s" type in the registry.', $name, $type));
    }
    return $this->assets[$type][$name];
}