当前位置: 首页>>代码示例>>PHP>>正文


PHP Processor::normalizeConfig方法代码示例

本文整理汇总了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;
 }
开发者ID:hermann106,项目名称:PasaGlProject,代码行数:19,代码来源:ArrayNode.php

示例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;
    }
开发者ID:Gregwar,项目名称:symfony,代码行数:69,代码来源:ArrayNode.php


注:本文中的Symfony\Component\Config\Definition\Processor::normalizeConfig方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。