public function AssetInjectorBase::preSave in Asset Injector 8
Same name and namespace in other branches
- 8.2 src/Entity/AssetInjectorBase.php \Drupal\asset_injector\Entity\AssetInjectorBase::preSave()
On update delete this asset's file(s), will be recreated later.
Overrides ConfigEntityBase::preSave
File
- src/
Entity/ AssetInjectorBase.php, line 169
Class
- AssetInjectorBase
- Class AssetInjectorBase: Base asset injector class.
Namespace
Drupal\asset_injector\EntityCode
public function preSave(EntityStorageInterface $storage) {
$original_id = $this
->getOriginalId();
if ($original_id) {
$original = $storage
->loadUnchanged($original_id);
// This happens to fail on config import.
if ($original instanceof AssetInjectorInterface) {
$asset_file_storage = new AssetFileStorage($original);
$asset_file_storage
->deleteFiles();
}
}
parent::preSave($storage);
}