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');
}