class GlobAsset

A collection of assets loaded by glob.

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

Hierarchy

Expanded class hierarchy of GlobAsset

1 file declares its use of GlobAsset
AssetFactory.php in drupal/core/vendor/kriswallsmith/assetic/src/Assetic/Factory/AssetFactory.php

File

drupal/core/vendor/kriswallsmith/assetic/src/Assetic/Asset/GlobAsset.php, line 22

Namespace

Assetic\Asset
View source
class GlobAsset extends AssetCollection {
  private $globs;
  private $initialized;

  /**
   * Constructor.
   *
   * @param string|array $globs   A single glob path or array of paths
   * @param array        $filters An array of filters
   * @param string       $root    The root directory
   * @param array        $vars
   */
  public function __construct($globs, $filters = array(), $root = null, array $vars = array()) {
    $this->globs = (array) $globs;
    $this->initialized = false;
    parent::__construct(array(), $filters, $root, $vars);
  }
  public function all() {
    if (!$this->initialized) {
      $this
        ->initialize();
    }
    return parent::all();
  }
  public function load(FilterInterface $additionalFilter = null) {
    if (!$this->initialized) {
      $this
        ->initialize();
    }
    parent::load($additionalFilter);
  }
  public function dump(FilterInterface $additionalFilter = null) {
    if (!$this->initialized) {
      $this
        ->initialize();
    }
    return parent::dump($additionalFilter);
  }
  public function getLastModified() {
    if (!$this->initialized) {
      $this
        ->initialize();
    }
    return parent::getLastModified();
  }
  public function getIterator() {
    if (!$this->initialized) {
      $this
        ->initialize();
    }
    return parent::getIterator();
  }
  public function setValues(array $values) {
    parent::setValues($values);
    $this->initialized = false;
  }

  /**
   * Initializes the collection based on the glob(s) passed in.
   */
  private function initialize() {
    foreach ($this->globs as $glob) {
      $glob = VarUtils::resolve($glob, $this
        ->getVars(), $this
        ->getValues());
      if (false !== ($paths = glob($glob))) {
        foreach ($paths as $path) {
          if (is_file($path)) {
            $this
              ->add(new FileAsset($path, array(), $this
              ->getSourceRoot()));
          }
        }
      }
    }
    $this->initialized = true;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AssetCollection::$assets private property
AssetCollection::$clones private property
AssetCollection::$content private property
AssetCollection::$filters private property
AssetCollection::$sourceRoot private property
AssetCollection::$targetPath private property
AssetCollection::$values private property
AssetCollection::$vars private property
AssetCollection::add public function Adds an asset to the current collection. Overrides AssetCollectionInterface::add
AssetCollection::clearFilters public function Clears all filters from the current asset. Overrides AssetInterface::clearFilters
AssetCollection::ensureFilter public function Ensures the current asset includes the supplied filter. Overrides AssetInterface::ensureFilter
AssetCollection::getContent public function Returns the loaded content of the current asset. Overrides AssetInterface::getContent
AssetCollection::getFilters public function Returns an array of filters currently applied. Overrides AssetInterface::getFilters
AssetCollection::getSourcePath public function Returns the relative path for the source asset. Overrides AssetInterface::getSourcePath
AssetCollection::getSourceRoot public function Returns an absolute path or URL to the source asset's root directory. Overrides AssetInterface::getSourceRoot
AssetCollection::getTargetPath public function Returns the URL for the current asset. Overrides AssetInterface::getTargetPath
AssetCollection::getValues public function Returns the current values for this asset. Overrides AssetInterface::getValues
AssetCollection::getVars public function Returns an array of variable names for this asset. Overrides AssetInterface::getVars
AssetCollection::removeLeaf public function Removes a leaf. Overrides AssetCollectionInterface::removeLeaf
AssetCollection::replaceLeaf public function Replaces an existing leaf with a new one. Overrides AssetCollectionInterface::replaceLeaf
AssetCollection::setContent public function Sets the content of the current asset. Overrides AssetInterface::setContent
AssetCollection::setTargetPath public function Sets the URL for the current asset. Overrides AssetInterface::setTargetPath
AssetCollection::__clone public function
GlobAsset::$globs private property
GlobAsset::$initialized private property
GlobAsset::all public function Returns all child assets. Overrides AssetCollection::all
GlobAsset::dump public function Applies dump filters and returns the asset as a string. Overrides AssetCollection::dump
GlobAsset::getIterator public function Returns an iterator for looping recursively over unique leaves. Overrides AssetCollection::getIterator
GlobAsset::getLastModified public function Returns the highest last-modified value of all assets in the current collection. Overrides AssetCollection::getLastModified
GlobAsset::initialize private function Initializes the collection based on the glob(s) passed in.
GlobAsset::load public function Loads the asset into memory and applies load filters. Overrides AssetCollection::load
GlobAsset::setValues public function Sets the values for the asset's variables. Overrides AssetCollection::setValues
GlobAsset::__construct public function Constructor. Overrides AssetCollection::__construct