class FilterCollection

A collection of filters.

@author Kris Wallsmith <kris.wallsmith@gmail.com>

Hierarchy

Expanded class hierarchy of FilterCollection

3 files declare their use of FilterCollection
AssetCollection.php in drupal/core/vendor/kriswallsmith/assetic/src/Assetic/Asset/AssetCollection.php
BaseAsset.php in drupal/core/vendor/kriswallsmith/assetic/src/Assetic/Asset/BaseAsset.php
FilterCollectionTest.php in drupal/core/vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/FilterCollectionTest.php

File

drupal/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/FilterCollection.php, line 21

Namespace

Assetic\Filter
View source
class FilterCollection implements FilterInterface, \IteratorAggregate, \Countable {
  private $filters = array();
  public function __construct($filters = array()) {
    foreach ($filters as $filter) {
      $this
        ->ensure($filter);
    }
  }

  /**
   * Checks that the current collection contains the supplied filter.
   *
   * If the supplied filter is another filter collection, each of its
   * filters will be checked.
   */
  public function ensure(FilterInterface $filter) {
    if ($filter instanceof \Traversable) {
      foreach ($filter as $f) {
        $this
          ->ensure($f);
      }
    }
    elseif (!in_array($filter, $this->filters, true)) {
      $this->filters[] = $filter;
    }
  }
  public function all() {
    return $this->filters;
  }
  public function clear() {
    $this->filters = array();
  }
  public function filterLoad(AssetInterface $asset) {
    foreach ($this->filters as $filter) {
      $filter
        ->filterLoad($asset);
    }
  }
  public function filterDump(AssetInterface $asset) {
    foreach ($this->filters as $filter) {
      $filter
        ->filterDump($asset);
    }
  }
  public function getIterator() {
    return new \ArrayIterator($this->filters);
  }
  public function count() {
    return count($this->filters);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FilterCollection::$filters private property
FilterCollection::all public function
FilterCollection::clear public function
FilterCollection::count public function
FilterCollection::ensure public function Checks that the current collection contains the supplied filter.
FilterCollection::filterDump public function Filters an asset just before it's dumped. Overrides FilterInterface::filterDump
FilterCollection::filterLoad public function Filters an asset after it has been loaded. Overrides FilterInterface::filterLoad
FilterCollection::getIterator public function
FilterCollection::__construct public function