コード例 #1
0
ファイル: ArrayNodeDefinition.php プロジェクト: kingsj/core
 /**
  * {@inheritDoc}
  */
 protected function createNode()
 {
     if (null == $this->prototype) {
         $node = new ArrayNode($this->name, $this->parent);
     } else {
         $node = new PrototypedArrayNode($this->name, $this->parent);
     }
     $node->setAddIfNotSet($this->addDefaults);
     $node->setAllowNewKeys($this->allowNewKeys);
     $node->addEquivalentValue(null, $this->nullEquivalent);
     $node->addEquivalentValue(true, $this->trueEquivalent);
     $node->addEquivalentValue(false, $this->falseEquivalent);
     $node->setPerformDeepMerging($this->performDeepMerging);
     $node->setRequired($this->required);
     $node->setIgnoreExtraKeys($this->ignoreExtraKeys);
     if (null !== $this->normalization) {
         $node->setNormalizationClosures($this->normalization->before);
         $node->setXmlRemappings($this->normalization->remappings);
     }
     if (null !== $this->merge) {
         $node->setAllowOverwrite($this->merge->allowOverwrite);
         $node->setAllowFalse($this->merge->allowFalse);
     }
     if (null !== $this->validation) {
         $node->setFinalValidationClosures($this->validation->rules);
     }
     if (null == $this->prototype) {
         foreach ($this->children as $child) {
             $child->parent = $node;
             $node->addChild($child->getNode());
         }
     } else {
         if (null !== $this->key) {
             $node->setKeyAttribute($this->key, $this->removeKeyItem);
         }
         if (true === $this->atLeastOne) {
             $node->setMinNumberOfElements(1);
         }
         if (null !== $this->defaultValue) {
             $node->setDefaultValue($this->defaultValue);
         }
         $this->prototype->parent = $node;
         $node->setPrototype($this->prototype->getNode());
     }
     return $node;
 }