SchulIT /
icc
| 1 | <?php |
||
| 2 | |||
| 3 | namespace App\Doctrine; |
||
| 4 | |||
| 5 | use App\Entity\Message; |
||
| 6 | use App\Entity\MessageAttachment; |
||
| 7 | use App\Filesystem\MessageFilesystem; |
||
| 8 | use Doctrine\Common\EventSubscriber; |
||
| 9 | use Doctrine\ORM\Event\LifecycleEventArgs; |
||
| 10 | use Doctrine\ORM\Events; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Listens to Message/MessageAttachment removals in order to remove files and directories from the filesystem. |
||
| 14 | */ |
||
| 15 | class MessageRemoveSubscriber implements EventSubscriber { |
||
| 16 | |||
| 17 | public function __construct(private MessageFilesystem $filesystem) |
||
| 18 | { |
||
| 19 | 25 | } |
|
| 20 | 25 | ||
| 21 | 25 | public function postRemove(LifecycleEventArgs $eventArgs) { |
|
| 22 | $entity = $eventArgs->getEntity(); |
||
|
0 ignored issues
–
show
|
|||
| 23 | 6 | ||
| 24 | 6 | if($entity instanceof Message) { |
|
| 25 | $this->filesystem->removeMessageDirectoy($entity); |
||
| 26 | 6 | } else if($entity instanceof MessageAttachment) { |
|
| 27 | $this->filesystem->removeMessageAttachment($entity); |
||
| 28 | 6 | } |
|
| 29 | } |
||
| 30 | |||
| 31 | 6 | /** |
|
| 32 | * @inheritDoc |
||
| 33 | */ |
||
| 34 | public function getSubscribedEvents(): array { |
||
| 35 | return [ |
||
| 36 | 25 | Events::postRemove |
|
| 37 | ]; |
||
| 38 | } |
||
| 39 | } |
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.