/**
  * Returns an array of usage reference objects.
  *
  * @param AssetInterface $asset
  * @return array<\TYPO3\Neos\Domain\Model\Dto\AssetUsageInNodeProperties>
  * @throws \TYPO3\TYPO3CR\Exception\NodeConfigurationException
  */
 public function getUsageReferences(AssetInterface $asset)
 {
     $assetIdentifier = $this->persistenceManager->getIdentifierByObject($asset);
     if (isset($this->firstlevelCache[$assetIdentifier])) {
         return $this->firstlevelCache[$assetIdentifier];
     }
     $userWorkspace = $this->userService->getPersonalWorkspace();
     $relatedNodes = [];
     foreach ($this->getRelatedNodes($asset) as $relatedNodeData) {
         $accessible = $this->domainUserService->currentUserCanReadWorkspace($relatedNodeData->getWorkspace());
         if ($accessible) {
             $context = $this->createContextMatchingNodeData($relatedNodeData);
         } else {
             $context = $this->createContentContext($userWorkspace->getName());
         }
         $site = $context->getCurrentSite();
         $node = $this->nodeFactory->createFromNodeData($relatedNodeData, $context);
         $flowQuery = new FlowQuery([$node]);
         /** @var \TYPO3\TYPO3CR\Domain\Model\NodeInterface $documentNode */
         $documentNode = $flowQuery->closest('[instanceof TYPO3.Neos:Document]')->get(0);
         $relatedNodes[] = new AssetUsageInNodeProperties($asset, $site, $documentNode, $node, $accessible);
     }
     $this->firstlevelCache[$assetIdentifier] = $relatedNodes;
     return $this->firstlevelCache[$assetIdentifier];
 }
 /**
  * Get Related Nodes for an asset
  *
  * @param Asset $asset
  * @return void
  */
 public function relatedNodesAction(Asset $asset)
 {
     $userWorkspace = $this->userService->getPersonalWorkspace();
     $relatedNodes = [];
     foreach ($this->getRelatedNodes($asset) as $relatedNodeData) {
         $accessible = $this->domainUserService->currentUserCanReadWorkspace($relatedNodeData->getWorkspace());
         if ($accessible) {
             $context = $this->createContextMatchingNodeData($relatedNodeData);
         } else {
             $context = $this->createContentContext($userWorkspace->getName());
         }
         $site = $context->getCurrentSite();
         $node = $this->nodeFactory->createFromNodeData($relatedNodeData, $context);
         $flowQuery = new FlowQuery([$node]);
         /** @var Node $documentNode */
         $documentNode = $flowQuery->closest('[instanceof TYPO3.Neos:Document]')->get(0);
         $documentNodeIdentifier = $documentNode instanceof NodeInterface ? $documentNode->getIdentifier() : null;
         $relatedNodes[$site->getNodeName()]['site'] = $site;
         $relatedNodes[$site->getNodeName()]['documentNodes'][$documentNodeIdentifier]['node'] = $documentNode;
         $relatedNodes[$site->getNodeName()]['documentNodes'][$documentNodeIdentifier]['nodes'][] = ['node' => $node, 'nodeData' => $relatedNodeData, 'contextDocumentNode' => $documentNode, 'accessible' => $accessible];
     }
     $this->view->assignMultiple(['asset' => $asset, 'relatedNodes' => $relatedNodes, 'contentDimensions' => $this->contentDimensionPresetSource->getAllPresets(), 'userWorkspace' => $userWorkspace]);
 }