Neos\ContentRepository\Domain\Service\NodeTypeManager::getNodeTypes PHP Method

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
    public function getNodeTypes($includeAbstractNodeTypes = true)
    {
        if ($this->cachedNodeTypes === array()) {
            $this->loadNodeTypes();
        }
        if ($includeAbstractNodeTypes) {
            return $this->cachedNodeTypes;
        }
        $nonAbstractNodeTypes = array_filter($this->cachedNodeTypes, function ($nodeType) {
            return !$nodeType->isAbstract();
        });
        return $nonAbstractNodeTypes;
    }

Usage Example

 /**
  * 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);
 }
All Usage Examples Of Neos\ContentRepository\Domain\Service\NodeTypeManager::getNodeTypes