findNodesByRelatedEntities() public method

Will return all possible NodeData objects that contain this identifiers. Note: This is an internal method that is likely to be replaced in the future. $objectTypeMap = array( 'Neos\Media\Domain\Model\Asset' => array('some-uuid-here'), 'Neos\Media\Domain\Model\ImageVariant' => array('some-uuid-here', 'another-uuid-here') )
public findNodesByRelatedEntities ( array $relationMap ) : array
$relationMap array
return array
 /**
  * Removes unused ImageVariants after a Node property changes to a different ImageVariant.
  * This is triggered via the nodePropertyChanged event.
  *
  * Note: This method it triggered by the "nodePropertyChanged" signal, @see \Neos\ContentRepository\Domain\Model\Node::emitNodePropertyChanged()
  *
  * @param NodeInterface $node the affected node
  * @param string $propertyName name of the property that has been changed/added
  * @param mixed $oldValue the property value before it was changed or NULL if the property is new
  * @param mixed $value the new property value
  * @return void
  */
 public function removeUnusedImageVariant(NodeInterface $node, $propertyName, $oldValue, $value)
 {
     if ($oldValue === $value || !$oldValue instanceof ImageVariant) {
         return;
     }
     $identifier = $this->persistenceManager->getIdentifierByObject($oldValue);
     $results = $this->nodeDataRepository->findNodesByRelatedEntities(array(ImageVariant::class => [$identifier]));
     // This case shouldn't happen as the query will usually find at least the node that triggered this call, still if there is no relation we can remove the ImageVariant.
     if ($results === []) {
         $this->assetRepository->remove($oldValue);
         return;
     }
     // If the result contains exactly the node that got a new ImageVariant assigned then we are safe to remove the asset here.
     if ($results === [$node->getNodeData()]) {
         $this->assetRepository->remove($oldValue);
     }
 }
 /**
  * @test
  */
 public function findNodesByRelatedEntitiesFindsExistingNodeWithMatchingEntityProperty()
 {
     $rootNode = $this->context->getRootNode();
     $newNode = $rootNode->createNode('test', $this->nodeTypeManager->getNodeType('Neos.ContentRepository.Testing:NodeTypeWithEntities'));
     $testImage = new Image();
     $this->persistenceManager->add($testImage);
     $newNode->setProperty('image', $testImage);
     $this->persistenceManager->persistAll();
     $relationMap = [Fixtures\Image::class => [$this->persistenceManager->getIdentifierByObject($testImage)]];
     $result = $this->nodeDataRepository->findNodesByRelatedEntities($relationMap);
     $this->assertCount(1, $result);
 }
 /**
  * Returns all nodes that use the asset in a node property.
  *
  * @param AssetInterface $asset
  * @return array
  */
 public function getRelatedNodes(AssetInterface $asset)
 {
     $relationMap = [];
     $relationMap[TypeHandling::getTypeForValue($asset)] = [$this->persistenceManager->getIdentifierByObject($asset)];
     if ($asset instanceof Image) {
         foreach ($asset->getVariants() as $variant) {
             $type = TypeHandling::getTypeForValue($variant);
             if (!isset($relationMap[$type])) {
                 $relationMap[$type] = [];
             }
             $relationMap[$type][] = $this->persistenceManager->getIdentifierByObject($variant);
         }
     }
     return $this->nodeDataRepository->findNodesByRelatedEntities($relationMap);
 }
 /**
  * Delete an asset
  *
  * @param \Neos\Media\Domain\Model\Asset $asset
  * @return void
  */
 public function deleteAction(\Neos\Media\Domain\Model\Asset $asset)
 {
     $relationMap = [];
     $relationMap[TypeHandling::getTypeForValue($asset)] = array($this->persistenceManager->getIdentifierByObject($asset));
     if ($asset instanceof \Neos\Media\Domain\Model\Image) {
         foreach ($asset->getVariants() as $variant) {
             $type = TypeHandling::getTypeForValue($variant);
             if (!isset($relationMap[$type])) {
                 $relationMap[$type] = [];
             }
             $relationMap[$type][] = $this->persistenceManager->getIdentifierByObject($variant);
         }
     }
     $relatedNodes = $this->nodeDataRepository->findNodesByRelatedEntities($relationMap);
     if (count($relatedNodes) > 0) {
         $this->addFlashMessage('Asset could not be deleted, because there are still Nodes using it.', '', Message::SEVERITY_WARNING, array(), 1412422767);
         $this->redirect('index');
     }
     // FIXME: Resources are not deleted, because we cannot be sure that the resource isn't used anywhere else.
     $this->assetRepository->remove($asset);
     $this->addFlashMessage(sprintf('Asset "%s" has been deleted.', $asset->getLabel()), null, null, array(), 1412375050);
     $this->redirect('index');
 }