public function HttpAsset::__construct

Constructor.

Parameters

string $sourceUrl The source URL:

array $filters An array of filters:

Throws

\InvalidArgumentException If the first argument is not an URL

Overrides BaseAsset::__construct

File

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

Class

HttpAsset
Represents an asset loaded via an HTTP request.

Namespace

Assetic\Asset

Code

public function __construct($sourceUrl, $filters = array(), $ignoreErrors = false, array $vars = array()) {
  if (0 === strpos($sourceUrl, '//')) {
    $sourceUrl = 'http:' . $sourceUrl;
  }
  elseif (false === strpos($sourceUrl, '://')) {
    throw new \InvalidArgumentException(sprintf('"%s" is not a valid URL.', $sourceUrl));
  }
  $this->sourceUrl = $sourceUrl;
  $this->ignoreErrors = $ignoreErrors;
  list($scheme, $url) = explode('://', $sourceUrl, 2);
  list($host, $path) = explode('/', $url, 2);
  parent::__construct($filters, $scheme . '://' . $host, $path, $vars);
}