Issues (964)

src/Doctrine/MessageRemoveSubscriber.php (1 issue)

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
Deprecated Code introduced by
The function Doctrine\ORM\Event\LifecycleEventArgs::getEntity() has been deprecated: 2.13. Use {@see getObject} instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

22
        $entity = /** @scrutinizer ignore-deprecated */ $eventArgs->getEntity();

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.

Loading history...
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
}