protected function parseInput($input) { // expand bundle notation if ('@' == $input[0] && false !== strpos($input, '/')) { $input = $this->kernel->locateResource($input); } return parent::parseInput($input); }
/** * 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); }
/** * 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); }
/** * 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); }
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); }
/** * 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']); }