Neos\Neos\Ui\TYPO3CR\Service\NodeService::getClosestDocument PHP Метод

getClosestDocument() публичный Метод

Helper method to retrieve the closest document for a node
public getClosestDocument ( TYPO3\TYPO3CR\Domain\Model\NodeInterface $node ) : TYPO3\TYPO3CR\Domain\Model\NodeInterface
$node TYPO3\TYPO3CR\Domain\Model\NodeInterface
Результат TYPO3\TYPO3CR\Domain\Model\NodeInterface
    public function getClosestDocument(NodeInterface $node)
    {
        if ($node->getNodeType()->isOfType('TYPO3.Neos:Document')) {
            return $node;
        }
        $flowQuery = new FlowQuery(array($node));
        return $flowQuery->closest('[instanceof TYPO3.Neos:Document]')->get(0);
    }

Usage Example

Пример #1
0
 /**
  * Get all publishable node context paths for a workspace
  *
  * @param Workspace $workspace
  * @return array
  */
 public function getPublishableNodeInfo(Workspace $workspace)
 {
     $publishableNodes = $this->publishingService->getUnpublishedNodes($workspace);
     $publishableNodes = array_map(function ($node) {
         if ($documentNode = $this->nodeService->getClosestDocument($node)) {
             return ['contextPath' => $node->getContextPath(), 'documentContextPath' => $documentNode->getContextPath()];
         }
     }, $publishableNodes);
     return array_filter($publishableNodes, function ($item) {
         return (bool) $item;
     });
 }
All Usage Examples Of Neos\Neos\Ui\TYPO3CR\Service\NodeService::getClosestDocument