resolveValue() public method

Replaces parameter placeholders (%name%) by their values.
public resolveValue ( mixed $value )
$value mixed A value
 /**
  * @return array
  */
 private function getIgnoredServicePatterns()
 {
     try {
         return (array) $this->parameterBag->resolveValue("%autowiring.ignored_services%");
     } catch (ParameterNotFoundException $exception) {
         return [];
     }
 }
示例#2
0
文件: XmlDriver.php 项目: sulu/sulu
 /**
  * Extracts filter type parameters from dom-node.
  *
  * @param \DOMXPath $xpath
  * @param \DOMNode $propertyNode
  *
  * @return array
  */
 protected function getFilterTypeParameters(\DOMXPath $xpath, \DOMNode $propertyNode)
 {
     $parameters = [];
     foreach ($xpath->query('x:filter-type-parameters/x:parameter', $propertyNode) as $parameterNode) {
         $key = XmlUtil::getValueFromXPath('@key', $xpath, $parameterNode);
         $parameters[$key] = $this->parameterBag->resolveValue(trim($parameterNode->nodeValue));
     }
     return $parameters;
 }
 /**
  * {@inheritdoc}
  */
 public function load($file, $type = null)
 {
     $path = $this->locator->locate($file);
     if (!class_exists('Symfony\\Component\\Yaml\\Parser')) {
         throw new \RuntimeException('Unable to load YAML config files as the Symfony Yaml Component is not installed.');
     }
     if (!stream_is_local($path)) {
         throw new \InvalidArgumentException(sprintf('This is not a local file "%s".', $path));
     }
     if (!file_exists($path)) {
         throw new \InvalidArgumentException(sprintf('File "%s" not found.', $path));
     }
     if (null === $this->yamlParser) {
         $this->yamlParser = new YamlParser();
     }
     try {
         $parsedConfig = $this->yamlParser->parse(file_get_contents($path));
     } catch (ParseException $e) {
         throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML.', $path), 0, $e);
     }
     if ($this->parameterBag) {
         $parsedConfig = $this->parameterBag->resolveValue($parsedConfig);
     }
     $collection = new RouteCollection();
     $collection->addResource(new FileResource($path));
     // empty file
     if (null === $parsedConfig) {
         return $collection;
     }
     // not an array
     if (!is_array($parsedConfig)) {
         throw new \InvalidArgumentException(sprintf('The file "%s" must contain a YAML array.', $path));
     }
     foreach ($parsedConfig as $name => $config) {
         $this->validate($config, $name, $path);
         if (isset($config['resource'])) {
             $this->parseImport($collection, $config, $path, $file);
         } else {
             $this->parseRoute($collection, $name, $config, $path);
         }
     }
     return $collection;
 }
示例#4
0
 /**
  * {@inheritdoc}
  */
 public function load($resource, $type = null)
 {
     $path = $this->locator->locate($resource);
     $content = $this->loadFile($path);
     // empty file
     if (null === $content) {
         return;
     }
     // imports
     $this->parseImports($content, $path);
     $content = $this->parameterBag->resolveValue($content);
     foreach ($content as $namespace => $values) {
         if (in_array($namespace, ['imports'])) {
             continue;
         }
         if (isset($this->container[$namespace]) && is_array($values)) {
             $values = $this->merge($this->container[$namespace], $values);
         }
         $this->container[$namespace] = $values;
     }
     return $content;
 }
 /**
  * Retrieve a value.
  *
  * @param string $path The path of the value.
  *
  * @return array|null
  */
 public function get($path)
 {
     // special case, root element.
     if ($path === static::PATH_SEPARATOR) {
         return $this->data;
     }
     $chunks = $this->splitPath($path);
     $scope = $this->data;
     if (empty($chunks)) {
         return null;
     }
     while (null !== ($sub = array_shift($chunks))) {
         if (isset($scope[$sub])) {
             $scope = $scope[$sub];
         } else {
             return null;
         }
     }
     return $this->parameterBag->resolveValue($scope);
 }
示例#6
0
文件: XmlDriver.php 项目: sulu/sulu
 /**
  * @param string $value
  *
  * @return string
  */
 protected function resolveParameter($value)
 {
     return $this->parameterBag->resolveValue($value);
 }