本文整理汇总了PHP中Symfony\Component\Config\Definition\Processor::normalizeConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP Processor::normalizeConfig方法的具体用法?PHP Processor::normalizeConfig怎么用?PHP Processor::normalizeConfig使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Config\Definition\Processor
的用法示例。
在下文中一共展示了Processor::normalizeConfig方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: remapXml
/**
* Remaps multiple singular values to a single plural value.
*
* @param array $value The source values
*
* @return array The remapped values
*/
protected function remapXml($value)
{
foreach ($this->xmlRemappings as $transformation) {
list($singular, $plural) = $transformation;
if (!isset($value[$singular])) {
continue;
}
$value[$plural] = Processor::normalizeConfig($value, $singular, $plural);
unset($value[$singular]);
}
return $value;
}
示例2: normalizeValue
/**
* Normalizes the value.
*
* @param mixed $value The value to normalize
* @return mixed The normalized value
*/
protected function normalizeValue($value)
{
if (false === $value) {
return $value;
}
foreach ($this->xmlRemappings as $transformation) {
list($singular, $plural) = $transformation;
if (!isset($value[$singular])) {
continue;
}
$value[$plural] = Processor::normalizeConfig($value, $singular, $plural);
unset($value[$singular]);
}
$normalized = array();
if (null !== $this->prototype) {
foreach ($value as $k => $v) {
if (null !== $this->keyAttribute && is_array($v)) {
if (!isset($v[$this->keyAttribute]) && is_int($k)) {
$msg = sprintf('The attribute "%s" must be set for path "%s".', $this->keyAttribute, $this->getPath());
throw new InvalidConfigurationException($msg);
} else if (isset($v[$this->keyAttribute])) {
$k = $v[$this->keyAttribute];
// remove the key attribute if configured to
if ($this->removeKeyAttribute) {
unset($v[$this->keyAttribute]);
}
}
if (array_key_exists($k, $normalized)) {
$msg = sprintf('Duplicate key "%s" for path "%s".', $k, $this->getPath());
throw new DuplicateKeyException($msg);
}
}
$this->prototype->setName($k);
if (null !== $this->keyAttribute) {
$normalized[$k] = $this->prototype->normalize($v);
} else {
$normalized[] = $this->prototype->normalize($v);
}
}
} else {
foreach ($this->children as $name => $child) {
if (array_key_exists($name, $value)) {
$normalized[$name] = $child->normalize($value[$name]);
unset($value[$name]);
}
}
// if extra fields are present, throw exception
if (count($value) && !$this->ignoreExtraKeys) {
$msg = sprintf('Unrecognized options "%s" under "%s"', implode(', ', array_keys($value)), $this->getPath());
throw new InvalidConfigurationException($msg);
}
}
return $normalized;
}