Example #1
0
 protected function fromXML(DOMElement $node)
 {
     $this->declaringNodeType = $node->getAttribute('declaringNodeType');
     $this->name = $node->getAttribute('name');
     $this->isAutoCreated = Helper::getBoolAttribute($node, 'isAutoCreated');
     $this->isMandatory = Helper::getBoolAttribute($node, 'mandatory');
     $this->isProtected = Helper::getBoolAttribute($node, 'isProtected');
     $this->onParentVersion = \PHPCR\Version\OnParentVersionAction::valueFromName($node->getAttribute('onParentVersion'));
 }
Example #2
0
 /**
  * @param \DOMElement $node
  * @return array
  */
 public function getItemDefinitionFromXml(DOMElement $node)
 {
     $data = array();
     $data['declaringNodeType'] = $node->getAttribute('declaringNodeType');
     $data['name'] = $node->getAttribute('name');
     $data['isAutoCreated'] = Helper::getBoolAttribute($node, 'isAutoCreated');
     $data['isMandatory'] = Helper::getBoolAttribute($node, 'mandatory');
     $data['isProtected'] = Helper::getBoolAttribute($node, 'isProtected');
     $data['onParentVersion'] = \PHPCR\Version\OnParentVersionAction::valueFromName($node->getAttribute('onParentVersion'));
     return $data;
 }
 private function getItemDefinitionMap()
 {
     return array('name' => function ($t, $v) {
         $t->setName($v);
     }, 'auto_created' => function ($t, $v) {
         $t->setAutoCreated((bool) $v);
     }, 'mandatory' => function ($t, $v) {
         $t->setMandatory((bool) $v);
     }, 'protected' => function ($t, $v) {
         $t->setProtected((bool) $v);
     }, 'on_parent_version' => function ($t, $v) {
         $t->setOnParentVersion(OnParentVersionAction::valueFromName($v));
     });
 }
 /**
  * @expectedException \InvalidArgumentException
  */
 public function testValueFromNameInvalid()
 {
     OnParentVersionAction::valueFromName('something');
 }
Example #5
0
 private function writeChildren($children)
 {
     if (null === $children) {
         // getDeclaredChildNodeDefinitions is allowed to return null on
         // newly created node type definitions
         return '';
     }
     $s = '';
     /** @var $child NodeDefinitionInterface */
     foreach ($children as $child) {
         $this->checkNamespace($child->getName());
         $s .= '+ ' . $child->getName();
         if ($child->getRequiredPrimaryTypeNames()) {
             foreach ($child->getRequiredPrimaryTypeNames() as $typeName) {
                 $this->checkNamespace($typeName);
             }
             $s .= ' (' . implode(', ', $child->getRequiredPrimaryTypeNames()) . ')';
         }
         if ($child->getDefaultPrimaryTypeName()) {
             $this->checkNamespace($child->getDefaultPrimaryTypeName());
             $s .= "\n= " . $child->getDefaultPrimaryTypeName();
         }
         $s .= "\n";
         $attributes = '';
         if ($child->isMandatory()) {
             $attributes .= 'mandatory ';
         }
         if ($child->isAutoCreated()) {
             $attributes .= 'autocreated ';
         }
         if ($child->isProtected()) {
             $attributes .= 'protected ';
         }
         if (OnParentVersionAction::COPY != $child->getOnParentVersion()) {
             $attributes .= OnParentVersionAction::nameFromValue($child->getOnParentVersion()) . ' ';
         }
         if ($child->allowsSameNameSiblings()) {
             $attributes .= 'sns ';
         }
         if ($attributes) {
             $s .= trim($attributes) . "\n";
         }
     }
     return $s;
 }
Example #6
0
 /**
  * The node attributes are indicated by the presence or absence of keywords.
  *
  * If 'autocreated' is present without a '?' then the item is autocreated.
  * If 'autocreated' is present with a '?' then the autocreated status is a variant.
  * If 'autocreated' is absent then the item is not autocreated.
  *
  * If 'mandatory' is present without a '?' then the item is mandatory.
  * If 'mandatory' is present with a '?' then the mandatory status is a variant.
  * If 'mandatory' is absent then the item is not mandatory.
  *
  * If 'protected' is present without a '?' then the item is protected.
  * If 'protected' is present with a '?' then the protected status is a variant.
  * If 'protected' is absent then the item is not protected.
  *
  * The OPV status of an item is indicated by the presence of that corresponding
  * keyword.
  * If no OPV keyword is present then an OPV status of COPY is assumed.
  * If the keyword 'OPV' followed by a '?' is present then the OPV status of the
  * item is a variant.
  *
  * If 'sns' is present without a '?' then the child node supports same-name siblings.
  * If 'sns' is present with a '?' then this attribute is a variant.
  * If 'sns' is absent then the child node does support same-name siblings.
  *
  *      NodeAttribute ::= Autocreated | Mandatory | Protected |
  *          Opv | Sns
  *      Autocreated ::= ('autocreated' | 'aut' | 'a' )['?']
  *      Mandatory ::= ('mandatory' | 'man' | 'm') ['?']
  *      Protected ::= ('protected' | 'pro' | 'p') ['?']
  *      Opv ::= 'COPY' | 'VERSION' | 'INITIALIZE' | 'COMPUTE' |
  *          'IGNORE' | 'ABORT' | ('OPV' '?')
  *      Sns ::= ('sns' | '*') ['?']
  */
 protected function parseChildNodeAttributes(NodeTypeTemplateInterface $parentType, NodeDefinitionTemplateInterface $childType)
 {
     while (true) {
         if ($this->checkTokenIn(Token::TK_IDENTIFIER, $this->PRIMARY)) {
             $parentType->setPrimaryItemName($childType->getName());
         } elseif ($this->checkTokenIn(Token::TK_IDENTIFIER, $this->AUTOCREATED)) {
             $childType->setAutoCreated(true);
         } elseif ($this->checkTokenIn(Token::TK_IDENTIFIER, $this->MANDATORY)) {
             $childType->setMandatory(true);
         } elseif ($this->checkTokenIn(Token::TK_IDENTIFIER, $this->PROTECTED)) {
             $childType->setProtected(true);
         } elseif ($this->checkTokenIn(Token::TK_IDENTIFIER, $this->SNS)) {
             $childType->setSameNameSiblings(true);
         } elseif ($this->checkTokenIn(Token::TK_IDENTIFIER, $this->OPV)) {
             $token = $this->tokenQueue->get();
             $childType->setOnParentVersion(OnParentVersionAction::valueFromName($token->getData()));
             continue;
         } else {
             return;
         }
         $this->tokenQueue->next();
     }
 }
 private function getItemDefinitionArray(ItemDefinitionInterface $id)
 {
     return array('name' => $id->getName(), 'auto_created' => (bool) $id->isAutoCreated(), 'mandatory' => (bool) $id->isMandatory(), 'on_parent_version' => OnParentVersionAction::nameFromValue($id->getOnParentVersion()), 'protected' => (bool) $id->isProtected());
 }