Bonjour,
Voici l'erreur que j'obtiens lorsque je tente de démarrer le serveur :
. Or, voici ma classe "ImageListener" :The service "App\Listeners\ImageListener" has a dependency on a non-existent parameter "path_image".
Quelqu'un aurait une idée?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91 <?php namespace AppBundle\Listeners; use Doctrine\ORM\Event\LifecycleEventArgs; use Liip\ImagineBundle\Imagine\Cache\CacheManager; use AppBundle\Entity\Image; use AppBundle\Services\ImageTransformer; use Vich\UploaderBundle\Event\Event; use Doctrine\ORM\EntityManagerInterface; /** * ImageListener */ class ImageListener { private $cacheManager; private $path_image; private $orm; public function __construct(CacheManager $cacheManager, EntityManagerInterface $orm, string $path_image) { $this->cacheManager = $cacheManager; $this->path_image = $path_image; $this->orm = $orm; } public function onVichUploaderPreInject(Event $args) { $entity = $args->getObject(); if (!$entity instanceof Image) { return; } $image = $entity->getImage(); $entity->setTmpFile($image); $this->orm->flush(); } public function postUpdate(LifecycleEventArgs $args) { $entity = $args->getEntity(); if (!$entity instanceof Image) { return; } $changeSet = $args->getEntityManager()->getUnitOfWork()->getEntityChangeSet($entity); if(!array_key_exists("image", $changeSet)){ return; } try { $this->cacheManager->remove($this->path_image.'/'.$entity->getTmpFile()); $this->cacheManager->resolve($this->path_image.'/'.$entity->getImage(), null); } catch (\Exception $e) { } } public function preRemove(LifecycleEventArgs $args) { $entity = $args->getEntity(); if (!$entity instanceof Image) { return; } $target = $this->path_image.'/'.$entity->getImage(); try { $this->cacheManager->remove($target); } catch (\Exception $e) { } } public function postPersist(LifecycleEventArgs $args) { $entity = $args->getObject(); if (!$entity instanceof Image) { return; } $file = $this->path_image.'/'.$entity->getImage(); } }
Merci d'avance pour votre aide...
Partager