Example #1
0
 /**
  * A child node definition consists of a node name element followed by optional
  * required node types, default node types  and node attributes elements.
  *
  * The node name, or '*' to indicate a residual property definition, is prefixed
  * with a '+'.
  *
  * The required primary node type list is delimited by parentheses. If this
  * element is missing then a required  primary node type of nt:base is assumed.
  * A '?' indicates that the this attribute is a variant.
  *
  *      ChildNodeDef ::= NodeName [RequiredTypes] [DefaultType]
  *          [NodeAttribute {NodeAttribute}]
  *      NodeName ::= '+' String
  *      RequiredTypes ::= '(' (StringList | '?') ')'
  *      DefaultType ::= '=' (String | '?')
  */
 protected function parseChildNodeDef(NodeTypeTemplateInterface $nodeType)
 {
     $this->expectToken(Token::TK_SYMBOL, '+');
     $childType = $this->ntm->createNodeDefinitionTemplate();
     $nodeType->getNodeDefinitionTemplates()->append($childType);
     // Parse the child name
     if ($this->checkAndExpectToken(Token::TK_SYMBOL, '*')) {
         $childType->setName('*');
     } else {
         $childType->setName($this->parseCndString());
     }
     // Parse the required primary types
     if ($this->checkAndExpectToken(Token::TK_SYMBOL, '(')) {
         if ($this->checkAndExpectToken(Token::TK_SYMBOL, '?')) {
             $list = '?';
         } else {
             $list = $this->parseCndStringList();
         }
         $this->expectToken(Token::TK_SYMBOL, ')');
         $childType->setRequiredPrimaryTypeNames($list);
     }
     // Parse the default primary type
     if ($this->checkAndExpectToken(Token::TK_SYMBOL, '=')) {
         $childType->setDefaultPrimaryTypeName($this->parseCndString());
     }
     $this->parseChildNodeAttributes($nodeType, $childType);
 }
Example #2
0
 /**
  * {@inheritDoc}
  *
  * @api
  */
 public function getMixinNodeTypes()
 {
     $this->checkNodeTypeEvent();
     $nt = array();
     foreach ($this->mixinNodeTypeNames as $name) {
         $nt[$name] = $this->ntm->getNodeType($name);
     }
     return $nt;
 }
 /**
  * @param QOM\SelectorInterface $source
  *
  * @return Term
  */
 public function walkSelectorSource(QOM\SelectorInterface $source)
 {
     $this->source = $source;
     $nodeTypeName = $source->getNodeTypeName();
     if (!$this->nodeTypeManager->hasNodeType($nodeTypeName)) {
         throw new InvalidQueryException(sprintf('Node type does not exist "%s"', $nodeTypeName));
     }
     return sprintf('%s:%s', $this->escape('jcr:primaryType'), $this->escape($source->getNodeTypeName()));
 }
 /**
  * @param QOM\SelectorInterface $source
  * @param string                $alias
  *
  * @return string
  */
 private function sqlNodeTypeClause($alias, QOM\SelectorInterface $source)
 {
     $sql = "{$alias}.type IN ('" . $source->getNodeTypeName() . "'";
     $subTypes = $this->nodeTypeManager->getSubtypes($source->getNodeTypeName());
     foreach ($subTypes as $subType) {
         /* @var $subType \PHPCR\NodeType\NodeTypeInterface */
         $sql .= ", '" . $subType->getName() . "'";
     }
     $sql .= ')';
     return $sql;
 }
 public function testGetMixinNodeTypes()
 {
     $types = $this->nodeTypeManager->getMixinNodeTypes();
     $this->assertInstanceOf('SeekableIterator', $types);
     $names = array();
     foreach ($types as $name => $type) {
         $this->assertInstanceOf('\\PHPCR\\NodeType\\NodeTypeInterface', $type);
         $this->assertEquals($name, $type->getName());
         $names[$name] = true;
     }
     foreach (self::$primary as $key) {
         $this->assertArrayNotHasKey($key, $names);
     }
     foreach (self::$mixins as $key) {
         $this->assertArrayHasKey($key, $names);
     }
 }
Example #6
0
 /**
  * {@inheritDoc}
  */
 public function getNode($path)
 {
     $this->assertLoggedIn();
     $path = $this->validatePath($path);
     $coll = $this->db->selectCollection(self::COLLNAME_NODES);
     $qb = $coll->createQueryBuilder()->field('path')->equals($path)->field('w_id')->equals($this->workspaceId);
     $query = $qb->getQuery();
     $node = $query->getSingleResult();
     if (!$node) {
         throw new ItemNotFoundException('Item ' . $path . ' not found.');
     }
     $data = new \stdClass();
     $data->{'jcr:primaryType'} = $node['type'];
     foreach ($node['props'] as $prop) {
         $name = $prop['name'];
         $type = $prop['type'];
         if ($type == PropertyType::TYPENAME_BINARY) {
             if (isset($prop['multi']) && $prop['multi'] == true) {
                 foreach ($prop['value'] as $value) {
                     $data->{":" . $name}[] = $value;
                 }
             } else {
                 $data->{":" . $name} = $prop['value'];
             }
         } elseif ($type == PropertyType::TYPENAME_DATE) {
             if (isset($prop['multi']) && $prop['multi'] == true) {
                 foreach ($prop['value'] as $value) {
                     $date = new \DateTime(date('Y-m-d H:i:s', $value['date']->sec), new \DateTimeZone($value['timezone']));
                     $data->{$name}[] = $date->format('c');
                 }
             } else {
                 $date = new \DateTime(date('Y-m-d H:i:s', $prop['value']['date']->sec), new \DateTimeZone($prop['value']['timezone']));
                 $data->{$name} = $date->format('c');
             }
             $data->{":" . $name} = $type;
         } elseif ($type == PropertyType::TYPENAME_BOOLEAN) {
             if (isset($prop['multi']) && $prop['multi'] == true) {
                 $booleanValue = array();
                 foreach ($prop['value'] as $booleanEntry) {
                     $booleanValue[] = $this->fetchBooleanPropertyValue($booleanEntry);
                 }
             } else {
                 $booleanValue = $this->fetchBooleanPropertyValue($prop['value']);
             }
             $data->{$name} = $booleanValue;
             $data->{":" . $name} = $type;
         } else {
             if (isset($prop['multi']) && $prop['multi'] == true) {
                 foreach ($prop['value'] as $value) {
                     $data->{$name}[] = $value;
                 }
             } else {
                 $data->{$name} = $prop['value'];
             }
             $data->{":" . $name} = $type;
         }
     }
     // If the node is referenceable, return jcr:uuid.
     if (isset($data->{"jcr:mixinTypes"})) {
         foreach ((array) $data->{"jcr:mixinTypes"} as $mixin) {
             if ($this->nodeTypeManager->getNodeType($mixin)->isNodeType('mix:referenceable') && $node['_id'] instanceof \MongoBinData) {
                 $data->{'jcr:uuid'} = $node['_id']->bin;
                 break;
             }
         }
     }
     $qb = $coll->createQueryBuilder()->field('parent')->equals($path)->field('w_id')->equals($this->workspaceId);
     $query = $qb->getQuery();
     $children = $query->getIterator();
     foreach ($children as $child) {
         $childName = explode('/', $child['path']);
         $childName = end($childName);
         $data->{$childName} = new \stdClass();
     }
     return $data;
 }
 /**
  * requires the implementation to support unstructured nodes.
  */
 public function testCanSetPropertyWildcard()
 {
     $undef = $this->ntm->getNodeType('nt:unstructured');
     $this->assertTrue($undef->canSetProperty('something', true));
 }