protected function getPrototypeNodeWithDefaultChildren()
 {
     $node = new PrototypedArrayNode('root');
     $prototype = new ArrayNode(null, $node);
     $child = new ScalarNode('foo');
     $child->setDefaultValue('bar');
     $prototype->addChild($child);
     $prototype->setAddIfNotSet(true);
     $node->setPrototype($prototype);
     return $node;
 }
Пример #2
0
 /**
  * Configures a scalar node.
  *
  * @param ScalarNode  $configNode The node to configure
  * @param NodeBuilder $node       The builder of the node
  */
 protected function configureScalarNode(ScalarNode $configNode, NodeBuilder $node)
 {
     if (null !== $node->normalization) {
         $configNode->setNormalizationClosures($this->buildExpressions($node->normalization->before));
     }
     if (null !== $node->merge) {
         $configNode->setAllowOverwrite($node->merge->allowOverwrite);
     }
     if (true === $node->default) {
         $configNode->setDefaultValue($node->defaultValue);
     }
     if (false === $node->allowEmptyValue) {
         $configNode->setAllowEmptyValue($node->allowEmptyValue);
     }
     $configNode->addEquivalentValue(null, $node->nullEquivalent);
     $configNode->addEquivalentValue(true, $node->trueEquivalent);
     $configNode->addEquivalentValue(false, $node->falseEquivalent);
     $configNode->setRequired($node->required);
     if (null !== $node->validation) {
         $configNode->setFinalValidationClosures($this->buildExpressions($node->validation->rules));
     }
 }