Skip to content

Commit 0a2dea6

Browse files
committed
Update afterDelete function in AssetsTable
Included explicit return type for the afterDelete function and made it use the asset's absolute_path for deletion instead of manually building the path. Also, the afterDelete function now accepts an Asset object instead of a general EntityInterface.
1 parent 824c3d1 commit 0a2dea6

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/Model/Table/AssetsTable.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
namespace Assets\Model\Table;
55

66
use ArrayObject;
7+
use Assets\Model\Entity\Asset;
78
use Cake\Core\Configure;
89
use Cake\Datasource\EntityInterface;
910
use Cake\Event\EventInterface;
@@ -131,11 +132,13 @@ public function beforeFind(EventInterface $e, Query $query, ArrayObject $options
131132
return $query->orderDesc('modified');
132133
}
133134

134-
public function afterDelete(EventInterface $e, EntityInterface $entity, ArrayObject $options)
135+
public function afterDelete(EventInterface $e, Asset $entity, ArrayObject $options): bool
135136
{
136137
if (Configure::read('AssetsPlugin.AssetsTable.deleteFile') === true) {
137-
FileSystem::delete(ROOT . DS . $entity->directory . $entity->filename);
138+
FileSystem::delete($entity->absolute_path);
138139
}
140+
141+
return true;
139142
}
140143

141144
/**

0 commit comments

Comments
 (0)