コード例 #1
0
ファイル: NodeTypeManager.php プロジェクト: rambo/jackalope
 /**
  * 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);
 }
コード例 #2
0
ファイル: NodeHelperSpec.php プロジェクト: hason/phpcr-shell
 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) {
     }
 }
コード例 #3
0
 /**
  * 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);
 }
コード例 #4
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);
         }
     }
 }