예제 #1
0
 /**
  * Copies properties from a NodeTypeDefinition
  * @param   \PHPCR\NodeType\NodeTypeDefinitionInterface  $ntd    The node type definition to copy properties from
  */
 protected function fromNodeTypeDefinition(\PHPCR\NodeType\NodeTypeDefinitionInterface $ntd)
 {
     $this->name = $ntd->getName();
     $this->isAbstract = $ntd->isAbstract();
     $this->isMixin = $ntd->isMixin();
     $this->isQueryable = $ntd->isQueryable();
     $this->hasOrderableChildNodes = $ntd->hasOrderableChildNodes();
     $this->primaryItemName = $ntd->getPrimaryItemName();
     $this->declaredSuperTypeNames = $ntd->getDeclaredSupertypeNames();
     $this->declaredPropertyDefinitions = new ArrayObject($ntd->getDeclaredPropertyDefinitions());
     $this->declaredNodeDefinitions = new ArrayObject($ntd->getDeclaredChildNodeDefinitions());
 }
예제 #2
0
 /**
  * Internally create a node type object
  *
  * @param NodeTypeDefinitionInterface $ntd
  * @param bool                        $allowUpdate whether updating the definition is to be allowed or not
  *
  * @return NodeType the new node type
  *
  * @throws \PHPCR\NodeType\NodeTypeExistsException
  */
 protected function createNodeType(NodeTypeDefinitionInterface $ntd, $allowUpdate)
 {
     if ($this->hasNodeType($ntd->getName()) && !$allowUpdate) {
         throw new NodeTypeExistsException('NodeType already existing: ' . $ntd->getName());
     }
     return $this->factory->get('NodeType\\NodeType', array($this, $ntd));
 }
예제 #3
0
 /**
  * A node type definition consists of a node type name followed by an optional
  * supertypes block, an optional node type attributes block and zero or more
  * blocks, each of which is either a property or child node definition.
  *
  *      NodeTypeDef ::= NodeTypeName [Supertypes]
  *          [NodeTypeAttribute {NodeTypeAttribute}]
  *          {PropertyDef | ChildNodeDef}
  */
 protected function writeNodeType(NodeTypeDefinitionInterface $nodeType)
 {
     $this->checkNamespace($nodeType->getName());
     $s = '[' . $nodeType->getName() . ']';
     if ($superTypes = $nodeType->getDeclaredSupertypeNames()) {
         foreach ($superTypes as $superType) {
             $this->checkNamespace($superType);
         }
         $s .= ' > ' . implode(', ', $superTypes);
     }
     $s .= "\n";
     $attributes = '';
     if ($nodeType->hasOrderableChildNodes()) {
         $attributes .= 'orderable ';
     }
     if ($nodeType->isMixin()) {
         $attributes .= 'mixin ';
     }
     if ($nodeType->isAbstract()) {
         $attributes .= 'abstract ';
     }
     $attributes .= $nodeType->isQueryable() ? 'query ' : 'noquery ';
     if ($nodeType->getPrimaryItemName()) {
         $attributes .= 'primaryitem ' . $nodeType->getPrimaryItemName() . ' ';
     }
     if ($attributes) {
         $s .= trim($attributes) . "\n";
     }
     $s .= $this->writeProperties($nodeType->getDeclaredPropertyDefinitions());
     $s .= $this->writeChildren($nodeType->getDeclaredChildNodeDefinitions());
     return $s;
 }