Neos\ContentRepository\Domain\Service\NodeTypeManager::getSubNodeTypes PHP Méthode

getSubNodeTypes() public méthode

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
Résultat array
    public function getSubNodeTypes($superTypeName, $includeAbstractNodeTypes = true)
    {
        if ($this->cachedNodeTypes === array()) {
            $this->loadNodeTypes();
        }
        if (isset($this->cachedSubNodeTypes[$superTypeName])) {
            return $this->cachedSubNodeTypes[$superTypeName];
        }
        $filteredNodeTypes = [];
        /** @var NodeType $nodeType */
        foreach ($this->cachedNodeTypes as $nodeTypeName => $nodeType) {
            if ($includeAbstractNodeTypes === false && $nodeType->isAbstract()) {
                continue;
            }
            if ($nodeType->isOfType($superTypeName) && $nodeTypeName !== $superTypeName) {
                $filteredNodeTypes[$nodeTypeName] = $nodeType;
            }
        }
        $this->cachedSubNodeTypes[$superTypeName] = $filteredNodeTypes;
        return $this->cachedSubNodeTypes[$superTypeName];
    }

Usage Example

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