remove() 공개 메소드

Remove an asset while first validating if the object can be removed or if removal is blocked because the asset is still in use.
public remove ( Neos\Media\Domain\Model\AssetInterface $object ) : void
$object Neos\Media\Domain\Model\AssetInterface
리턴 void
 /**
  * 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);
     }
 }
 /**
  * Delete an asset
  *
  * @param Asset $asset
  * @return void
  */
 public function deleteAction(Asset $asset)
 {
     try {
         $this->assetRepository->remove($asset);
         $this->addFlashMessage('assetHasBeenDeleted', '', Message::SEVERITY_OK, [htmlspecialchars($asset->getLabel())]);
     } catch (AssetServiceException $exception) {
         $this->addFlashMessage('assetCouldNotBeDeleted', '', Message::SEVERITY_WARNING, [], 1462196565);
     }
     $this->redirect('index');
 }