Ejemplo n.º 1
0
 /**
  * Stores the node type in our internal structures (flat && tree)
  *
  * @param   \PHPCR\NodeType\NodeTypeInterface  $nodetype   The nodetype to add
  */
 protected function addNodeType(\PHPCR\NodeType\NodeTypeInterface $nodetype)
 {
     if ($nodetype->isMixin()) {
         $this->mixinTypes[$nodetype->getName()] = $nodetype;
     } else {
         $this->primaryTypes[$nodetype->getName()] = $nodetype;
     }
     $this->addToNodeTree($nodetype);
 }
Ejemplo n.º 2
0
 public function it_should_provide_a_method_to_determine_if_a_node_is_versionable(NodeInterface $nodeVersionable, NodeInterface $nodeNotVersionable, NodeTypeInterface $mixin1, NodeTypeInterface $mixin2)
 {
     $nodeVersionable->getMixinNodeTypes()->willReturn(array($mixin1, $mixin2));
     $nodeNotVersionable->getMixinNodeTypes()->willReturn(array($mixin2));
     $nodeNotVersionable->getPath()->willReturn('foobar');
     $mixin1->getName()->willReturn('mix:versionable');
     $this->assertNodeIsVersionable($nodeVersionable)->shouldReturn(null);
     try {
         $this->assertNodeIsVersionable($nodeNotVersionable);
     } catch (\OutOfBoundsException $e) {
     }
 }
 /**
  * Convert a node type into YAML format
  *
  * @param NodeTypeInterface
  *
  * @return string
  */
 public function serialize(NodeTypeInterface $nt)
 {
     $out = array('name' => $nt->getName(), 'declared_supertypes' => $nt->getDeclaredSupertypeNames(), 'abstract' => (bool) $nt->isAbstract(), 'mixin' => (bool) $nt->isMixin(), 'orderable_child_nodes' => (bool) $nt->hasOrderableChildNodes(), 'queryable' => (bool) $nt->isQueryable(), 'primary_item' => $nt->getPrimaryItemName(), 'properties' => array(), 'children' => array());
     foreach ($nt->getDeclaredPropertyDefinitions() as $pd) {
         $property = $this->getItemDefinitionArray($pd);
         $property = array_merge($property, array('required_type' => PropertyType::nameFromValue($pd->getRequiredType()), 'value_constraints' => $pd->getValueConstraints(), 'default_values' => $pd->getDefaultValues(), 'multiple' => (bool) $pd->isMultiple(), 'available_query_operators' => $pd->getAvailableQueryOperators(), 'full_text_searchable' => (bool) $pd->isFullTextSearchable(), 'query_orderable' => (bool) $pd->isQueryOrderable()));
         $out['properties'][] = $property;
     }
     foreach ($nt->getDeclaredChildNodeDefinitions() as $cd) {
         $child = $this->getItemDefinitionArray($cd);
         $child = array_merge($child, array('required_primary_types' => $cd->getRequiredPrimaryTypeNames(), 'default_primary_type' => $cd->getDefaultPrimaryTypeName(), 'same_name_siblings' => (bool) $cd->allowsSameNameSiblings()));
         $out['children'][] = $child;
     }
     return Yaml::dump($out, 10);
 }
 public function setUp()
 {
     parent::setUp();
     try {
         $defs = self::$base->getPropertyDefinitions();
         $this->assertInternalType('array', $defs);
         foreach ($defs as $def) {
             $this->assertInstanceOf('\\PHPCR\\NodeType\\PropertyDefinitionInterface', $def);
             switch ($def->getName()) {
                 case 'jcr:primaryType':
                     $this->primaryType = $def;
                     break;
                 case 'jcr:mixinTypes':
                     $this->mixinTypes = $def;
                     break;
             }
         }
         $this->assertNotNull($this->primaryType);
         $this->assertNotNull($this->mixinTypes);
         $defs = self::$address->getPropertyDefinitions();
         $this->assertInternalType('array', $defs);
         foreach ($defs as $def) {
             $this->assertInstanceOf('\\PHPCR\\NodeType\\PropertyDefinitionInterface', $def);
             switch ($def->getName()) {
                 case 'jcr:workspace':
                     $this->workspace = $def;
                     break;
                 case 'jcr:path':
                     $this->pathprop = $def;
                     break;
                 case 'jcr:id':
                     $this->id = $def;
                     break;
             }
         }
         $this->assertNotNull($this->workspace);
         $this->assertNotNull($this->pathprop);
         $this->assertNotNull($this->id);
         $defs = self::$mix_created->getPropertyDefinitions();
         $this->assertInternalType('array', $defs);
         foreach ($defs as $def) {
             $this->assertInstanceOf('\\PHPCR\\NodeType\\PropertyDefinitionInterface', $def);
             if ('jcr:created' == $def->getName()) {
                 $this->created = $def;
             }
         }
         $this->assertNotNull($this->created);
         $defs = self::$resource->getPropertyDefinitions();
         $this->assertInternalType('array', $defs);
         foreach ($defs as $def) {
             $this->assertInstanceOf('\\PHPCR\\NodeType\\PropertyDefinitionInterface', $def);
             if ('jcr:data' == $def->getName()) {
                 $this->data = $def;
             }
         }
         $this->assertNotNull($this->data);
     } catch (\Exception $e) {
         $this->markTestSkipped('getChildNodeDefinitions not working as it should, skipping tests about NodeDefinitionInterface: ' . $e->getMessage());
     }
 }
 public function testCanRemoveProperty()
 {
     $this->assertTrue($this->file->canRemoveProperty('notdefined'));
     $this->assertTrue($this->file->canRemoveProperty('jcr:content'));
     // this is a child, not a property...
     $this->assertTrue($this->file->canRemoveProperty('jcr:mimeType'));
     $this->assertFalse($this->file->canRemoveProperty('jcr:created'));
 }
 public function setUp()
 {
     parent::setUp();
     try {
         $defs = self::$file->getChildNodeDefinitions();
         $this->assertInternalType('array', $defs);
         $this->assertCount(1, $defs);
         list($key, $this->content) = each($defs);
         $this->assertInstanceOf('\\PHPCR\\NodeType\\NodeDefinitionInterface', $this->content);
         $this->assertEquals('jcr:content', $this->content->getName());
         $defs = self::$folder->getChildNodeDefinitions();
         $this->assertInternalType('array', $defs);
         $this->assertCount(1, $defs);
         list($key, $this->hierarchyNodeDef) = each($defs);
         $this->assertInstanceOf('\\PHPCR\\NodeType\\NodeDefinitionInterface', $this->hierarchyNodeDef);
         $this->assertEquals('*', $this->hierarchyNodeDef->getName());
     } catch (\Exception $e) {
         $this->markTestSkipped('getChildNodeDefinitions not working as it should, skipping tests about NodeDefinitionInterface: ' . $e->getMessage());
     }
 }
Ejemplo n.º 7
0
 /**
  * Adds the declared super types of a node type to the tree to be able to
  * fetch the sub types of those super types later on.
  *
  * Part of addNodeType.
  *
  * @param NodeTypeInterface $nodetype the node type to add.
  */
 private function addToNodeTree($nodetype)
 {
     foreach ($nodetype->getDeclaredSupertypeNames() as $declaredSupertypeName) {
         if (isset($this->nodeTree[$declaredSupertypeName])) {
             $this->nodeTree[$declaredSupertypeName] = array_merge($this->nodeTree[$declaredSupertypeName], array($nodetype->getName() => $nodetype));
         } else {
             $this->nodeTree[$declaredSupertypeName] = array($nodetype->getName() => $nodetype);
         }
     }
 }
Ejemplo n.º 8
0
 public function testIsNodeTypeMixin()
 {
     $this->assertTrue(self::$created->isNodeType('mix:created'));
     $this->assertFalse(self::$created->isNodeType('mix:createdBy'));
 }