getNodeTypes() public method

Return all registered node types.
public getNodeTypes ( boolean $includeAbstractNodeTypes = true ) : array
$includeAbstractNodeTypes boolean Whether to include abstract node types, defaults to TRUE
return array
 /**
  * Returns the node types that the currently authenticated user is *denied* to create within the given $referenceNode
  *
  * @param NodeInterface $referenceNode
  * @return string[] Array of granted node type names
  */
 public function getNodeTypeNamesDeniedForCreation(NodeInterface $referenceNode)
 {
     $privilegeSubject = new CreateNodePrivilegeSubject($referenceNode);
     $allNodeTypes = $this->nodeTypeManager->getNodeTypes();
     $deniedCreationNodeTypes = array();
     $grantedCreationNodeTypes = array();
     $abstainedCreationNodeTypes = array();
     foreach ($this->securityContext->getRoles() as $role) {
         /** @var CreateNodePrivilege $createNodePrivilege */
         foreach ($role->getPrivilegesByType(CreateNodePrivilege::class) as $createNodePrivilege) {
             if (!$createNodePrivilege->matchesSubject($privilegeSubject)) {
                 continue;
             }
             $affectedNodeTypes = $createNodePrivilege->getCreationNodeTypes() !== array() ? $createNodePrivilege->getCreationNodeTypes() : $allNodeTypes;
             if ($createNodePrivilege->isGranted()) {
                 $grantedCreationNodeTypes = array_merge($grantedCreationNodeTypes, $affectedNodeTypes);
             } elseif ($createNodePrivilege->isDenied()) {
                 $deniedCreationNodeTypes = array_merge($deniedCreationNodeTypes, $affectedNodeTypes);
             } else {
                 $abstainedCreationNodeTypes = array_merge($abstainedCreationNodeTypes, $affectedNodeTypes);
             }
         }
     }
     $implicitlyDeniedNodeTypes = array_diff($abstainedCreationNodeTypes, $grantedCreationNodeTypes);
     return array_merge($implicitlyDeniedNodeTypes, $deniedCreationNodeTypes);
 }
 /**
  * Converts the nodes types to a fully structured array
  * in the same structure as the schema to be created.
  *
  * The schema also includes abstract node types for the full inheritance information in VIE.
  *
  * @return object
  */
 public function generateVieSchema()
 {
     if ($this->configuration !== null) {
         return $this->configuration;
     }
     $nodeTypes = $this->nodeTypeManager->getNodeTypes();
     foreach ($nodeTypes as $nodeTypeName => $nodeType) {
         $this->readNodeTypeConfiguration($nodeTypeName, $nodeType);
     }
     unset($this->types['typo3:unstructured']);
     foreach ($this->types as $nodeTypeName => $nodeTypeDefinition) {
         $this->types[$nodeTypeName]->subtypes = $this->getAllSubtypes($nodeTypeName);
         $this->types[$nodeTypeName]->ancestors = $this->getAllAncestors($nodeTypeName);
         $this->removeUndeclaredTypes($this->types[$nodeTypeName]->supertypes);
         $this->removeUndeclaredTypes($this->types[$nodeTypeName]->ancestors);
     }
     foreach ($this->properties as $property => $propertyConfiguration) {
         if (isset($propertyConfiguration->domains) && is_array($propertyConfiguration->domains)) {
             foreach ($propertyConfiguration->domains as $domain) {
                 if (preg_match('/TYPO3\\.Neos\\.NodeTypes:.*Column/', $domain)) {
                     $this->properties[$property]->ranges = array_keys($this->types);
                 }
             }
         }
     }
     // Convert the Neos.Neos:ContentCollection element to support content-collection
     // TODO Move to node type definition
     if (isset($this->types['typo3:Neos.Neos:ContentCollection'])) {
         $this->addProperty('typo3:Neos.Neos:ContentCollection', 'typo3:content-collection', array());
         $this->types['typo3:Neos.Neos:ContentCollection']->specific_properties[] = 'typo3:content-collection';
         $this->properties['typo3:content-collection']->ranges = array_keys($this->types);
     }
     $this->configuration = (object) array('types' => (object) $this->types, 'properties' => (object) $this->properties);
     return $this->configuration;
 }
 /**
  * Reorder child nodes according to the current position configuration of child nodes.
  *
  * @param string $workspaceName Name of the workspace to consider
  * @param boolean $dryRun Simulate?
  * @param NodeType $nodeType Only for this node type, if specified
  * @return void
  */
 protected function reorderChildNodes($workspaceName, $dryRun, NodeType $nodeType = null)
 {
     if ($nodeType !== null) {
         $this->output->outputLine('Checking nodes of type "%s" for child nodes that need reordering ...', array($nodeType->getName()));
         $this->reorderChildNodesByNodeType($workspaceName, $dryRun, $nodeType);
     } else {
         $this->output->outputLine('Checking for child nodes that need reordering ...');
         foreach ($this->nodeTypeManager->getNodeTypes() as $nodeType) {
             /** @var NodeType $nodeType */
             if ($nodeType->isAbstract()) {
                 continue;
             }
             $this->reorderChildNodesByNodeType($workspaceName, $dryRun, $nodeType);
         }
     }
     $this->persistenceManager->persistAll();
 }
 /**
  * @Then /^I should get the list of all available node types as denied node types for this node from the node authorization service$/
  */
 public function iShouldGetTheListOfAllAvailableNodeTypesAsDeniedNodeTypesForThisNodeFromTheNodeAuthorizationService()
 {
     if ($this->isolated === true) {
         $this->callStepInSubProcess(__METHOD__);
     } else {
         $availableNodeTypes = $this->nodeTypeManager->getNodeTypes();
         $deniedNodeTypeNames = $this->nodeAuthorizationService->getNodeTypeNamesDeniedForCreation($this->currentNodes[0]);
         if (count($availableNodeTypes) !== count($deniedNodeTypeNames)) {
             Assert::fail('The node authorization service did not return the expected amount of node type names! Got: ' . implode(', ', $deniedNodeTypeNames));
         }
         foreach ($availableNodeTypes as $nodeType) {
             if (in_array($nodeType, $deniedNodeTypeNames) === false) {
                 Assert::fail('The following node type name has not been returned by the node authorization service: ' . $nodeType);
             }
         }
     }
 }
 /**
  * Generate the list of allowed sub-node-types per parent-node-type and child-node-name.
  *
  * @return array constraints
  */
 protected function generateConstraints()
 {
     $constraints = array();
     $nodeTypes = $this->nodeTypeManager->getNodeTypes(true);
     /** @var NodeType $nodeType */
     foreach ($nodeTypes as $nodeTypeName => $nodeType) {
         $constraints[$nodeTypeName] = array('nodeTypes' => array(), 'childNodes' => array());
         foreach ($nodeTypes as $innerNodeTypeName => $innerNodeType) {
             if ($nodeType->allowsChildNodeType($innerNodeType)) {
                 $constraints[$nodeTypeName]['nodeTypes'][$innerNodeTypeName] = true;
             }
         }
         foreach ($nodeType->getAutoCreatedChildNodes() as $key => $_x) {
             foreach ($nodeTypes as $innerNodeTypeName => $innerNodeType) {
                 if ($nodeType->allowsGrandchildNodeType($key, $innerNodeType)) {
                     $constraints[$nodeTypeName]['childNodes'][$key]['nodeTypes'][$innerNodeTypeName] = true;
                 }
             }
         }
     }
     return $constraints;
 }
Example #6
0
 /**
  * Generate TypoScript prototype definitions for all node types
  *
  * Only fully qualified node types (e.g. MyVendor.MyPackage:NodeType) will be considered.
  *
  * @return string
  */
 protected function generateNodeTypeDefinitions()
 {
     $code = '';
     /** @var NodeType $nodeType */
     foreach ($this->nodeTypeManager->getNodeTypes(false) as $nodeType) {
         $code .= $this->generateTypoScriptForNodeType($nodeType);
     }
     return $code;
 }
 /**
  * @test
  */
 public function getNodeTypesWithoutIncludeAbstractContainsNoAbstractNodeTypes()
 {
     $nodeTypes = $this->nodeTypeManager->getNodeTypes(false);
     $this->assertArrayNotHasKey('Neos.ContentRepository.Testing:ContentObject', $nodeTypes);
 }