Back to WebAssetManager class

Method disableAsset

public self
disableAsset
(string $type, string $name)
Deactivate an asset item, so it will not be attached to a Document
Parameters
  • string $type The asset type, script or style
  • string $name The asset name
Returns
  • self
Since
  • 4.0.0
-
  • \Joomla\CMS\WebAsset\Exception\UnknownAssetException When Asset cannot be found
  • \Joomla\CMS\WebAsset\Exception\InvalidActionException When the Manager already attached to a Document

Method disableAsset - Source code

/**
 * Deactivate an asset item, so it will not be attached to a Document
 *
 * @param   string  $type  The asset type, script or style
 * @param   string  $name  The asset name
 *
 * @return  self
 *
 * @throws  UnknownAssetException  When Asset cannot be found
 * @throws  InvalidActionException When the Manager already attached to a Document
 *
 * @since  4.0.0
 */
public function disableAsset(string $type, string $name) : WebAssetManagerInterface
{
    if ($this->locked) {
        throw new InvalidActionException('WebAssetManager is locked, you came late');
    }
    // Check whether asset exists
    $this->registry->get($type, $name);
    unset($this->activeAssets[$type][$name]);
    // To re-check dependencies
    $this->dependenciesIsActual = false;
    // For Preset case
    if ($type === 'preset') {
        $this->disablePresetItems($name);
    }
    return $this;
}