本文整理汇总了PHP中Assetic\Factory\AssetFactory::parseInput方法的典型用法代码示例。如果您正苦于以下问题:PHP AssetFactory::parseInput方法的具体用法?PHP AssetFactory::parseInput怎么用?PHP AssetFactory::parseInput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assetic\Factory\AssetFactory
的用法示例。
在下文中一共展示了AssetFactory::parseInput方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseInput
protected function parseInput($input)
{
// expand bundle notation
if ('@' == $input[0] && false !== strpos($input, '/')) {
$input = $this->kernel->locateResource($input);
}
return parent::parseInput($input);
}
示例2: parseInput
/**
* Will detect inputs that begin with @MyNamespace/... and replace the namespace with the corresponding path.
*
* @see \Assetic\Factory\AssetFactory::parseInput()
*/
protected function parseInput($input, array $options = array())
{
$matches = null;
// search for @MyNamespace/path/to/asset
if (preg_match("|^\\@([a-z_][_a-z0-9]*)/|i", $input, $matches)) {
$ns = $matches[1];
if (!array_key_exists($ns, $this->namespaces)) {
throw new \RuntimeException("{$ns} : unknown namespace !");
}
$input = $this->namespaces[$ns] . substr($input, strlen($ns) + 1);
}
return parent::parseInput($input, $options);
}
示例3: parseInput
/**
* Adds support for bundle notation and globs.
*
* Please note this is a naive implementation of globs in that it doesn't
* attempt to support bundle inheritance within the glob pattern itself.
*/
protected function parseInput($input)
{
// expand bundle notation
if ('@' == $input[0] && false !== strpos($input, '/')) {
if (false !== ($pos = strpos($input, '*'))) {
// locateResource() does not support globs so we provide a naive implementation here
list($before, $after) = explode('*', $input, 2);
$input = $this->kernel->locateResource($before) . '*' . $after;
} else {
$input = $this->kernel->locateResource($input);
}
}
return parent::parseInput($input);
}
示例4: parseInput
/**
* Adds support for bundle notation file and glob assets.
*
* FIXME: This is a naive implementation of globs in that it doesn't
* attempt to support bundle inheritance within the glob pattern itself.
*/
protected function parseInput($input, array $options = array())
{
// expand bundle notation
if ('@' == $input[0] && false !== strpos($input, '/')) {
// use the bundle path as this asset's root
$bundle = substr($input, 1);
if (false !== ($pos = strpos($bundle, '/'))) {
$bundle = substr($bundle, 0, $pos);
}
$options['root'] = array($this->kernel->getBundle($bundle)->getPath());
// canonicalize the input
if (false !== ($pos = strpos($input, '*'))) {
// locateResource() does not support globs so we provide a naive implementation here
list($before, $after) = explode('*', $input, 2);
$input = $this->kernel->locateResource($before) . '*' . $after;
} else {
$input = $this->kernel->locateResource($input);
}
}
return parent::parseInput($input, $options);
}
示例5: parseInput
protected function parseInput($input, array $options = array())
{
$input = $this->parameterBag->resolveValue($input);
if ('@' == $input[0] && false !== strpos($input, '/')) {
$bundle = substr($input, 1);
if (false !== ($pos = strpos($bundle, '/'))) {
$bundle = substr($bundle, 0, $pos);
}
$options['root'] = array($this->kernel->getBundle($bundle)->getPath());
if (false !== ($pos = strpos($input, '*'))) {
list($before, $after) = explode('*', $input, 2);
$input = $this->kernel->locateResource($before) . '*' . $after;
} else {
$input = $this->kernel->locateResource($input);
}
}
return parent::parseInput($input, $options);
}
示例6: parseInput
/**
* Converts an input to an asset.
*
* An "input" in Assetic's terminology is a reference string to an asset,
* such as "css/*.css", "/webmozart/puli/style.css",
* "@AcmeDemoBundle/Resources/css/style.css" etc.
*
* The input may contain variables whose name are passed in the "vars"
* option. For example, an input with the variable "locale" could look like
* this: "js/messages.{locale}.js".
*
* If the input contains no variables, the decision whether the input
* refers to a file or a Puli asset is made immediately using the resolution
* logic described in {@link PuliAssetFactory}.
*
* If the input contains variables, that decision is deferred until the
* values of the variables are known. In this case, a {@link LazyAsset}
* is returned.
*
* @param string $input The input string.
* @param array $options Additional options to be used.
*
* @return AssetInterface The created asset.
*/
protected function parseInput($input, array $options = array())
{
if (!$this->mayBePuliInput($input)) {
return parent::parseInput($input, $options);
}
// Puli URIs can be resolved immediately
if (false !== strpos($input, '://')) {
return $this->createPuliAsset($input, $options['vars']);
}
// Check whether we deal with a Puli asset or a file asset as soon as
// the variable values have been set
if (0 === count($options['vars'])) {
return $this->parseInputWithFixedValues($input, $options['current_dir'], $options['root']);
}
// parseInputWithFixedValues() is called as soon as the variable values
// are set
return new LazyAsset($this, $input, $options['current_dir'], $options['root'], $options['vars']);
}