Back to WebAssetManager class

Method getAssetState

public int
getAssetState
(string $type, string $name)
Get a state for the Asset
Parameters
  • string $type The asset type, script or style
  • string $name The asset name
Returns
  • int
Since
  • 4.0.0
-
  • \Joomla\CMS\WebAsset\Exception\UnknownAssetException When Asset cannot be found

Method getAssetState - Source code

/**
 * Get a state for the Asset
 *
 * @param   string  $type  The asset type, script or style
 * @param   string  $name  The asset name
 *
 * @return  integer
 *
 * @throws  UnknownAssetException  When Asset cannot be found
 *
 * @since  4.0.0
 */
public function getAssetState(string $type, string $name) : int
{
    // Check whether asset exists first
    $this->registry->get($type, $name);
    // Make sure that all dependencies are active
    if (!$this->dependenciesIsActual) {
        $this->enableDependencies();
    }
    if (!empty($this->activeAssets[$type][$name])) {
        return $this->activeAssets[$type][$name];
    }
    return static::ASSET_STATE_INACTIVE;
}