getKeyAttribute() public method

Retrieves the name of the attribute which value should be used as key.
public getKeyAttribute ( ) : string
return string The name of the attribute
コード例 #1
0
 /**
  * @param PrototypedArrayNode $node
  *
  * @return array
  */
 private function getPrototypeChildren(PrototypedArrayNode $node)
 {
     $prototype = $node->getPrototype();
     $key = $node->getKeyAttribute();
     // Do not expand prototype if it isn't an array node nor uses attribute as key
     if (!$key && !$prototype instanceof ArrayNode) {
         return $node->getChildren();
     }
     if ($prototype instanceof ArrayNode) {
         $keyNode = new ArrayNode($key, $node);
         $children = $prototype->getChildren();
         if ($prototype instanceof PrototypedArrayNode && $prototype->getKeyAttribute()) {
             $children = $this->getPrototypeChildren($prototype);
         }
         // add children
         foreach ($children as $childNode) {
             $keyNode->addChild($childNode);
         }
     } else {
         $keyNode = new ScalarNode($key, $node);
     }
     $info = 'Prototype';
     if (null !== $prototype->getInfo()) {
         $info .= ': ' . $prototype->getInfo();
     }
     $keyNode->setInfo($info);
     return array($key => $keyNode);
 }