public function FileAsset::__construct

Constructor.

Parameters

string $source An absolute path:

array $filters An array of filters:

string $sourceRoot The source asset root directory:

string $sourcePath The source asset path:

Throws

\InvalidArgumentException If the supplied root doesn't match the source when guessing the path

Overrides BaseAsset::__construct

File

drupal/core/vendor/kriswallsmith/assetic/src/Assetic/Asset/FileAsset.php, line 36

Class

FileAsset
Represents an asset loaded from a file.

Namespace

Assetic\Asset

Code

public function __construct($source, $filters = array(), $sourceRoot = null, $sourcePath = null, array $vars = array()) {
  if (null === $sourceRoot) {
    $sourceRoot = dirname($source);
    if (null === $sourcePath) {
      $sourcePath = basename($source);
    }
  }
  elseif (null === $sourcePath) {
    if (0 !== strpos($source, $sourceRoot)) {
      throw new \InvalidArgumentException(sprintf('The source "%s" is not in the root directory "%s"', $source, $sourceRoot));
    }
    $sourcePath = substr($source, strlen($sourceRoot) + 1);
  }
  $this->source = $source;
  parent::__construct($filters, $sourceRoot, $sourcePath, $vars);
}