getSubNodeTypes() public method

Return all non-abstract node types which have a certain $superType, without the $superType itself.
public getSubNodeTypes ( string $superTypeName, boolean $includeAbstractNodeTypes = true ) : array
$superTypeName string
$includeAbstractNodeTypes boolean Whether to include abstract node types, defaults to TRUE
return array
 /**
  * @param QueryInterface $query
  * @param $nodeTypeFilter
  * @return array
  */
 protected function getNodeTypeFilterConstraints(QueryInterface $query, $nodeTypeFilter)
 {
     $includeNodeTypeConstraints = [];
     $excludeNodeTypeConstraints = [];
     $nodeTypeFilterParts = Arrays::trimExplode(',', $nodeTypeFilter);
     foreach ($nodeTypeFilterParts as $nodeTypeFilterPart) {
         $nodeTypeFilterPart = trim($nodeTypeFilterPart);
         if (strpos($nodeTypeFilterPart, '!') === 0) {
             $negate = true;
             $nodeTypeFilterPart = substr($nodeTypeFilterPart, 1);
         } else {
             $negate = false;
         }
         $nodeTypeFilterPartSubTypes = array_merge([$nodeTypeFilterPart], $this->nodeTypeManager->getSubNodeTypes($nodeTypeFilterPart, false));
         foreach ($nodeTypeFilterPartSubTypes as $nodeTypeFilterPartSubType) {
             if ($negate === true) {
                 $excludeNodeTypeConstraints[] = $query->logicalNot($query->equals('nodeType', $nodeTypeFilterPartSubType));
             } else {
                 $includeNodeTypeConstraints[] = $query->equals('nodeType', $nodeTypeFilterPartSubType);
             }
         }
     }
     $constraints = $excludeNodeTypeConstraints;
     if (count($includeNodeTypeConstraints) > 0) {
         $constraints[] = $query->logicalOr($includeNodeTypeConstraints);
     }
     return $constraints;
 }
 /**
  * Search a page, needed for internal links.
  *
  * @deprecated will be removed with 3.0, use Service/NodesController->indexAction() instead
  * @param string $query
  * @return void
  */
 public function searchPageAction($query)
 {
     $searchResult = array();
     $documentNodeTypes = $this->nodeTypeManager->getSubNodeTypes('Neos.Neos:Document');
     /** @var NodeInterface $node */
     foreach ($this->nodeSearchService->findByProperties($query, $documentNodeTypes, $this->createContext('live')) as $node) {
         $searchResult[$node->getPath()] = $this->processNodeForEditorPlugins($node);
     }
     $this->view->assign('value', array('searchResult' => $searchResult, 'success' => true));
 }
 /**
  * The preprocessed node type schema contains everything we need for the UI:
  *
  * - "nodeTypes" contains the original (merged) node type schema
  * - "inheritanceMap.subTypes" contains for every parent type the transitive list of subtypes
  * - "constraints" contains for each node type, the list of allowed child node types; normalizing
  *   whitelists and blacklists:
  *   - [node type]
  *     - nodeTypes:
  *       [child node type name]: TRUE
  *     - childNodes:
  *       - [child node name]
  *         - nodeTypes:
  *          [child node type name]: TRUE
  *
  * @return array the node type schema ready to be used by the JavaScript code
  */
 public function generateNodeTypeSchema()
 {
     $schema = array('inheritanceMap' => array('subTypes' => array()), 'nodeTypes' => array(), 'constraints' => $this->generateConstraints());
     $nodeTypes = $this->nodeTypeManager->getNodeTypes(true);
     /** @var NodeType $nodeType */
     foreach ($nodeTypes as $nodeTypeName => $nodeType) {
         if ($nodeType->isAbstract() === false) {
             $configuration = $nodeType->getFullConfiguration();
             $this->flattenAlohaFormatOptions($configuration);
             $schema['nodeTypes'][$nodeTypeName] = $configuration;
             $schema['nodeTypes'][$nodeTypeName]['label'] = $nodeType->getLabel();
         }
         $schema['inheritanceMap']['subTypes'][$nodeTypeName] = array();
         foreach ($this->nodeTypeManager->getSubNodeTypes($nodeType->getName(), true) as $subNodeType) {
             /** @var NodeType $subNodeType */
             $schema['inheritanceMap']['subTypes'][$nodeTypeName][] = $subNodeType->getName();
         }
     }
     return $schema;
 }
 /**
  * @param string|array $nodeTypes
  * @return PropertyConditionGenerator
  */
 public function nodeIsOfType($nodeTypes)
 {
     $propertyConditionGenerator = new PropertyConditionGenerator('nodeType');
     if (!is_array($nodeTypes)) {
         $nodeTypes = array($nodeTypes);
     }
     $expandedNodeTypeNames = array();
     foreach ($nodeTypes as $nodeTypeName) {
         $subNodeTypes = $this->nodeTypeManager->getSubNodeTypes($nodeTypeName, false);
         $expandedNodeTypeNames = array_merge($expandedNodeTypeNames, array($nodeTypeName), array_keys($subNodeTypes));
     }
     return $propertyConditionGenerator->in(array_unique($expandedNodeTypeNames));
 }
 /**
  * Reorder child nodes for the given node type
  *
  * @param string $workspaceName
  * @param boolean $dryRun
  * @param NodeType $nodeType
  * @return void
  */
 protected function reorderChildNodesByNodeType($workspaceName, $dryRun, NodeType $nodeType)
 {
     $nodeTypes = $this->nodeTypeManager->getSubNodeTypes($nodeType->getName(), false);
     $nodeTypes[$nodeType->getName()] = $nodeType;
     if ($this->nodeTypeManager->hasNodeType((string) $nodeType)) {
         $nodeType = $this->nodeTypeManager->getNodeType((string) $nodeType);
         $nodeTypeNames[$nodeType->getName()] = $nodeType;
     } else {
         $this->output->outputLine('Node type "%s" does not exist', array((string) $nodeType));
         exit(1);
     }
     /** @var $nodeType NodeType */
     foreach ($nodeTypes as $nodeTypeName => $nodeType) {
         $childNodes = $nodeType->getAutoCreatedChildNodes();
         if ($childNodes === array()) {
             continue;
         }
         foreach ($this->getNodeDataByNodeTypeAndWorkspace($nodeTypeName, $workspaceName) as $nodeData) {
             /** @var NodeInterface $childNodeBefore */
             $childNodeBefore = null;
             $context = $this->nodeFactory->createContextMatchingNodeData($nodeData);
             $node = $this->nodeFactory->createFromNodeData($nodeData, $context);
             if (!$node instanceof NodeInterface) {
                 continue;
             }
             foreach ($childNodes as $childNodeName => $childNodeType) {
                 $childNode = $node->getNode($childNodeName);
                 if ($childNode) {
                     if ($childNodeBefore) {
                         if ($dryRun === false) {
                             if ($childNodeBefore->getIndex() >= $childNode->getIndex()) {
                                 $childNode->moveAfter($childNodeBefore);
                                 $this->output->outputLine('Moved node named "%s" after node named "%s" in "%s"', array($childNodeName, $childNodeBefore->getName(), $node->getPath()));
                             }
                         } else {
                             $this->output->outputLine('Should move node named "%s" after node named "%s" in "%s"', array($childNodeName, $childNodeBefore->getName(), $node->getPath()));
                         }
                     }
                 } else {
                     $this->output->outputLine('Missing child node named "%s" in "%s".', array($childNodeName, $node->getPath()));
                 }
                 $childNodeBefore = $childNode;
             }
         }
     }
 }
Example #6
0
 /**
  * Return child nodes of specified node for usage in a TreeLoader based on filter
  *
  * @param Node $node The node to find child nodes for
  * @param string $term
  * @param string $nodeType
  * @return void
  */
 public function filterChildNodesForTreeAction(Node $node, $term, $nodeType)
 {
     $nodeTypes = strlen($nodeType) > 0 ? array($nodeType) : array_keys($this->nodeTypeManager->getSubNodeTypes('Neos.Neos:Document', false));
     $context = $node->getContext();
     if ($term !== '') {
         $nodes = $this->nodeSearchService->findByProperties($term, $nodeTypes, $context, $node);
     } else {
         $nodes = array();
         $nodeDataRecords = $this->nodeDataRepository->findByParentAndNodeTypeRecursively($node->getPath(), implode(',', $nodeTypes), $context->getWorkspace(), $context->getDimensions());
         foreach ($nodeDataRecords as $nodeData) {
             $matchedNode = $this->nodeFactory->createFromNodeData($nodeData, $context);
             if ($matchedNode !== null) {
                 $nodes[$matchedNode->getPath()] = $matchedNode;
             }
         }
     }
     $this->view->assignFilteredChildNodes($node, $nodes);
 }
 /**
  * Fetch a PluginView definition that matches the specified controller and action combination
  *
  * @param string $controllerObjectName
  * @param string $actionName
  * @return PluginViewDefinition
  * @throws Neos\Exception if more than one PluginView matches the given controller/action pair
  */
 public function getPluginViewDefinitionByAction($controllerObjectName, $actionName)
 {
     $pluginNodeTypes = $this->nodeTypeManager->getSubNodeTypes('Neos.Neos:Plugin', false);
     $matchingPluginViewDefinitions = [];
     foreach ($pluginNodeTypes as $pluginNodeType) {
         /** @var $pluginViewDefinition PluginViewDefinition */
         foreach ($this->getPluginViewDefinitionsByPluginNodeType($pluginNodeType) as $pluginViewDefinition) {
             if ($pluginViewDefinition->matchesControllerActionPair($controllerObjectName, $actionName) !== true) {
                 continue;
             }
             $matchingPluginViewDefinitions[] = $pluginViewDefinition;
         }
     }
     if (count($matchingPluginViewDefinitions) > 1) {
         throw new Neos\Exception(sprintf('More than one PluginViewDefinition found for controller "%s", action "%s":%s', $controllerObjectName, $actionName, chr(10) . implode(chr(10), $matchingPluginViewDefinitions)), 1377597671);
     }
     return count($matchingPluginViewDefinitions) > 0 ? current($matchingPluginViewDefinitions) : null;
 }
 /**
  * Shows a list of nodes
  *
  * @param string $searchTerm An optional search term used for filtering the list of nodes
  * @param array $nodeIdentifiers An optional list of node identifiers
  * @param string $workspaceName Name of the workspace to search in, "live" by default
  * @param array $dimensions Optional list of dimensions and their values which should be used for querying
  * @param array $nodeTypes A list of node types the list should be filtered by
  * @param NodeInterface $contextNode a node to use as context for the search
  * @return string
  */
 public function indexAction($searchTerm = '', array $nodeIdentifiers = array(), $workspaceName = 'live', array $dimensions = array(), array $nodeTypes = array('Neos.Neos:Document'), NodeInterface $contextNode = null)
 {
     $searchableNodeTypeNames = array();
     foreach ($nodeTypes as $nodeTypeName) {
         if (!$this->nodeTypeManager->hasNodeType($nodeTypeName)) {
             $this->throwStatus(400, sprintf('Unknown node type "%s"', $nodeTypeName));
         }
         $searchableNodeTypeNames[$nodeTypeName] = $nodeTypeName;
         /** @var NodeType $subNodeType */
         foreach ($this->nodeTypeManager->getSubNodeTypes($nodeTypeName, false) as $subNodeTypeName => $subNodeType) {
             $searchableNodeTypeNames[$subNodeTypeName] = $subNodeTypeName;
         }
     }
     $contentContext = $this->createContentContext($workspaceName, $dimensions);
     if ($nodeIdentifiers === array()) {
         $nodes = $this->nodeSearchService->findByProperties($searchTerm, $searchableNodeTypeNames, $contentContext, $contextNode);
     } else {
         $nodes = array_map(function ($identifier) use($contentContext) {
             return $contentContext->getNodeByIdentifier($identifier);
         }, $nodeIdentifiers);
     }
     $this->view->assign('nodes', $nodes);
 }
 /**
  * @test
  */
 public function getSubNodeTypesWithoutIncludeAbstractContainsNoAbstractNodeTypes()
 {
     $nodeTypes = $this->nodeTypeManager->getSubNodeTypes('Neos.ContentRepository.Testing:ContentObject', false);
     $this->assertArrayNotHasKey('Neos.ContentRepository.Testing:AbstractType', $nodeTypes);
 }
 /**
  * Create a new site form.
  *
  * @param Site $site Site to create
  * @Flow\IgnoreValidation("$site")
  * @return void
  */
 public function newSiteAction(Site $site = null)
 {
     $sitePackages = $this->packageManager->getFilteredPackages('active', null, 'neos-site');
     $documentNodeTypes = $this->nodeTypeManager->getSubNodeTypes('Neos.Neos:Document', false);
     $this->view->assignMultiple(array('sitePackages' => $sitePackages, 'documentNodeTypes' => $documentNodeTypes, 'site' => $site, 'generatorServiceIsAvailable' => $this->packageManager->isPackageActive('Neos.SiteKickstarter')));
 }