Neos\Neos\TypoScript\Helper\NodeHelper::nearestContentCollection PHP 메소드

nearestContentCollection() 공개 메소드

Check if the given node is already a collection, find collection by nodePath otherwise, throw exception if no content collection could be found
public nearestContentCollection ( Neos\ContentRepository\Domain\Model\NodeInterface $node, string $nodePath ) : Neos\ContentRepository\Domain\Model\NodeInterface
$node Neos\ContentRepository\Domain\Model\NodeInterface
$nodePath string
리턴 Neos\ContentRepository\Domain\Model\NodeInterface
    public function nearestContentCollection(NodeInterface $node, $nodePath)
    {
        $contentCollectionType = 'Neos.Neos:ContentCollection';
        if ($node->getNodeType()->isOfType($contentCollectionType)) {
            return $node;
        } else {
            if ((string) $nodePath === '') {
                throw new Exception(sprintf('No content collection of type %s could be found in the current node and no node path was provided. You might want to configure the nodePath property with a relative path to the content collection.', $contentCollectionType), 1409300545);
            }
            $subNode = $node->getNode($nodePath);
            if ($subNode !== null && $subNode->getNodeType()->isOfType($contentCollectionType)) {
                return $subNode;
            } else {
                throw new Exception(sprintf('No content collection of type %s could be found in the current node (%s) or at the path "%s". You might want to adjust your node type configuration and create the missing child node through the "flow node:repair --node-type %s" command.', $contentCollectionType, $node->getPath(), $nodePath, (string) $node->getNodeType()), 1389352984);
            }
        }
    }