protected function AssetFactory::parseInput

Parses an input string string into an asset.

The input string can be one of the following:

  • A reference: If the string starts with an "at" sign it will be interpreted as a reference to an asset in the asset manager
  • An absolute URL: If the string contains "://" or starts with "//" it will be interpreted as an HTTP asset
  • A glob: If the string contains a "*" it will be interpreted as a glob
  • A path: Otherwise the string is interpreted as a filesystem path

Both globs and paths will be absolutized using the current root directory.

Parameters

string $input An input string:

array $options An array of options:

Return value

AssetInterface An asset

1 call to AssetFactory::parseInput()
AssetFactory::createAsset in drupal/core/vendor/kriswallsmith/assetic/src/Assetic/Factory/AssetFactory.php
Creates a new asset.

File

drupal/core/vendor/kriswallsmith/assetic/src/Assetic/Factory/AssetFactory.php, line 267

Class

AssetFactory
The asset factory creates asset objects.

Namespace

Assetic\Factory

Code

protected function parseInput($input, array $options = array()) {
  if ('@' == $input[0]) {
    return $this
      ->createAssetReference(substr($input, 1));
  }
  if (false !== strpos($input, '://') || 0 === strpos($input, '//')) {
    return $this
      ->createHttpAsset($input, $options['vars']);
  }
  if (self::isAbsolutePath($input)) {
    if ($root = self::findRootDir($input, $options['root'])) {
      $path = ltrim(substr($input, strlen($root)), '/');
    }
    else {
      $path = null;
    }
  }
  else {
    $root = $this->root;
    $path = $input;
    $input = $this->root . '/' . $path;
  }
  if (false !== strpos($input, '*')) {
    return $this
      ->createGlobAsset($input, $root, $options['vars']);
  }
  return $this
    ->createFileAsset($input, $root, $path, $options['vars']);
}