Neos\Media\Domain\Service\AssetService::validateRemoval PHP Метод

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

Validates if the asset can be removed
public validateRemoval ( Neos\Media\Domain\Model\AssetInterface $asset ) : void
$asset Neos\Media\Domain\Model\AssetInterface
Результат void
    public function validateRemoval(AssetInterface $asset)
    {
        if ($asset instanceof ImageVariant) {
            return;
        }
        if ($this->isInUse($asset)) {
            throw new AssetServiceException('Asset could not be deleted, because it is still in use.', 1462196420);
        }
    }

Usage Example

 /**
  * Remove an asset while first validating if the object can be removed or
  * if removal is blocked because the asset is still in use.
  *
  * @param AssetInterface $object
  * @return void
  */
 public function remove($object)
 {
     $this->assetService->validateRemoval($object);
     parent::remove($object);
     $this->assetService->emitAssetRemoved($object);
 }