hasNodeType() public method

Checks if the specified node type exists
public hasNodeType ( string $nodeTypeName ) : boolean
$nodeTypeName string Name of the node type
return boolean TRUE if it exists, otherwise FALSE
 /**
  * Repair inconsistent nodes
  *
  * This command analyzes and repairs the node tree structure and individual nodes
  * based on the current node type configuration.
  *
  * It is possible to execute only one or more specific checks by providing the <b>--skip</b>
  * or <b>--only</b> option. See the full description of checks further below for possible check
  * identifiers.
  *
  * The following checks will be performed:
  *
  * {pluginDescriptions}
  * <b>Examples:</b>
  *
  * ./flow node:repair
  *
  * ./flow node:repair --node-type Neos.NodeTypes:Page
  *
  * ./flow node:repair --workspace user-robert --only removeOrphanNodes,removeNodesWithInvalidDimensions
  *
  * ./flow node:repair --skip removeUndefinedProperties
  *
  * @param string $nodeType Node type name, if empty update all declared node types
  * @param string $workspace Workspace name, default is 'live'
  * @param boolean $dryRun Don't do anything, but report actions
  * @param boolean $cleanup If FALSE, cleanup tasks are skipped
  * @param string $skip Skip the given check or checks (comma separated)
  * @param string $only Only execute the given check or checks (comma separated)
  * @return void
  */
 public function repairCommand($nodeType = null, $workspace = 'live', $dryRun = false, $cleanup = true, $skip = null, $only = null)
 {
     $this->pluginConfigurations = self::detectPlugins($this->objectManager);
     if ($this->workspaceRepository->countByName($workspace) === 0) {
         $this->outputLine('Workspace "%s" does not exist', array($workspace));
         exit(1);
     }
     if ($nodeType !== null) {
         if ($this->nodeTypeManager->hasNodeType($nodeType)) {
             $nodeType = $this->nodeTypeManager->getNodeType($nodeType);
         } else {
             $this->outputLine('Node type "%s" does not exist', array($nodeType));
             exit(1);
         }
     }
     if ($dryRun) {
         $this->outputLine('Dry run, not committing any changes.');
     }
     if (!$cleanup) {
         $this->outputLine('Omitting cleanup tasks.');
     }
     foreach ($this->pluginConfigurations as $pluginConfiguration) {
         /** @var NodeCommandControllerPluginInterface $plugin */
         $plugin = $pluginConfiguration['object'];
         $this->outputLine('<b>' . $plugin->getSubCommandShortDescription('repair') . '</b>');
         $this->outputLine();
         $plugin->invokeSubCommand('repair', $this->output, $nodeType, $workspace, $dryRun, $cleanup, $skip, $only);
         $this->outputLine();
     }
     $this->outputLine('Node repair finished.');
 }
 /**
  * Render the label for the given $nodeTypeName
  *
  * @param string $nodeTypeName
  * @throws NodeTypeNotFoundException
  * @return string
  */
 public function labelForNodeType($nodeTypeName)
 {
     if (!$this->nodeTypeManager->hasNodeType($nodeTypeName)) {
         $explodedNodeTypeName = explode(':', $nodeTypeName);
         return end($explodedNodeTypeName);
     }
     $nodeType = $this->nodeTypeManager->getNodeType($nodeTypeName);
     return $nodeType->getLabel();
 }
 /**
  * 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);
 }
 /**
  * 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;
             }
         }
     }
 }
 /**
  * @test
  */
 public function hasNodeTypeReturnsTrueForAbstractNodeTypes()
 {
     $this->assertTrue($this->nodeTypeManager->hasNodeType('Neos.ContentRepository.Testing:ContentObject'));
 }
 /**
  * If the given node has the property this transformation should work on, this
  * returns TRUE if the given NodeType is registered with the NodeTypeManager and is not abstract.
  *
  * @param NodeData $node
  * @return boolean
  */
 public function isTransformable(NodeData $node)
 {
     return $this->nodeTypeManager->hasNodeType($this->newType) && !$this->nodeTypeManager->getNodeType($this->newType)->isAbstract();
 }