コード例 #1
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);
 }
コード例 #2
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);
         }
     }
 }