public function AssetCollection::removeLeaf

Removes a leaf.

Parameters

AssetInterface $leaf The leaf to remove:

Boolean $graceful Whether the failure should return false or throw an exception:

Return value

Boolean Whether the asset has been found

Throws

\InvalidArgumentException If the asset cannot be found

Overrides AssetCollectionInterface::removeLeaf

File

drupal/core/vendor/kriswallsmith/assetic/src/Assetic/Asset/AssetCollection.php, line 73

Class

AssetCollection
A collection of assets.

Namespace

Assetic\Asset

Code

public function removeLeaf(AssetInterface $needle, $graceful = false) {
  foreach ($this->assets as $i => $asset) {
    $clone = isset($this->clones[$asset]) ? $this->clones[$asset] : null;
    if (in_array($needle, array(
      $asset,
      $clone,
    ), true)) {
      unset($this->clones[$asset], $this->assets[$i]);
      return true;
    }
    if ($asset instanceof AssetCollectionInterface && $asset
      ->removeLeaf($needle, true)) {
      return true;
    }
  }
  if ($graceful) {
    return false;
  }
  throw new \InvalidArgumentException('Leaf not found.');
}