1 | <?php |
||
25 | class DoctrineListener implements EventSubscriber { |
||
26 | |||
27 | /** |
||
28 | * |
||
29 | * @var EntityToDocumentMapperInterface |
||
30 | */ |
||
31 | protected $entityToDocumentMapper; |
||
32 | |||
33 | /** |
||
34 | * |
||
35 | * @var SearchService |
||
36 | */ |
||
37 | protected $searchService; |
||
38 | |||
39 | /** |
||
40 | * @var bool |
||
41 | */ |
||
42 | protected $needsFlush = false; |
||
43 | |||
44 | /** |
||
45 | * @var bool |
||
46 | */ |
||
47 | protected $enableIndexing; |
||
48 | |||
49 | /** |
||
50 | * @var EventDispatcherInterface|null |
||
51 | */ |
||
52 | protected $eventDispatcher; |
||
53 | |||
54 | /** |
||
55 | * DoctrineListener constructor. |
||
56 | * @param EntityToDocumentMapperInterface $entityToDocumentMapper |
||
57 | * @param SearchService $searchService |
||
58 | * @param bool $enableIndexing |
||
59 | */ |
||
60 | public function __construct(EntityToDocumentMapperInterface $entityToDocumentMapper, SearchService $searchService, $enableIndexing = false) { |
||
65 | |||
66 | /** |
||
67 | * @return array|string[] |
||
68 | */ |
||
69 | public function getSubscribedEvents(): array { |
||
77 | |||
78 | /** |
||
79 | * @return EventDispatcherInterface|null |
||
80 | */ |
||
81 | public function getEventDispatcher(): ?EventDispatcherInterface { |
||
84 | |||
85 | /** |
||
86 | * @param EventDispatcherInterface|null $eventDispatcher |
||
87 | * @required |
||
88 | */ |
||
89 | public function setEventDispatcher(EventDispatcherInterface $eventDispatcher = null): void { |
||
92 | |||
93 | |||
94 | /** |
||
95 | * |
||
96 | */ |
||
97 | public function enableIndexing(): void { |
||
100 | |||
101 | /** |
||
102 | * |
||
103 | */ |
||
104 | public function disableIndexing(): void { |
||
107 | |||
108 | /** |
||
109 | * @return bool |
||
110 | */ |
||
111 | public function isIndexingEnabled(): bool { |
||
114 | |||
115 | /** |
||
116 | * Index the entity after it is persisted for the first time |
||
117 | * |
||
118 | * @param LifecycleEventArgs $args |
||
119 | */ |
||
120 | public function postPersist(LifecycleEventArgs $args): void { |
||
126 | |||
127 | /** |
||
128 | * @param PostFlushEventArgs $eventArgs |
||
129 | * @throws \Doctrine\ORM\ORMException |
||
130 | * @throws \Doctrine\ORM\OptimisticLockException |
||
131 | */ |
||
132 | public function postFlush(PostFlushEventArgs $eventArgs): void { |
||
138 | |||
139 | /** |
||
140 | * Removes the entity from the index when it marked for deletion |
||
141 | * |
||
142 | * @param LifecycleEventArgs $args |
||
143 | */ |
||
144 | public function preRemove(LifecycleEventArgs $args): void { |
||
150 | |||
151 | /** |
||
152 | * Updates the entity in the index after it is updated |
||
153 | * |
||
154 | * @param LifecycleEventArgs $args |
||
155 | */ |
||
156 | public function postUpdate(LifecycleEventArgs $args): void { |
||
160 | |||
161 | /** |
||
162 | * |
||
163 | * @return EntityToDocumentMapperInterface |
||
164 | */ |
||
165 | protected function getEntityToDocumentMapper(): EntityToDocumentMapperInterface { |
||
168 | |||
169 | /** |
||
170 | * |
||
171 | * @return SearchService |
||
172 | */ |
||
173 | protected function getSearchService(): SearchService { |
||
176 | |||
177 | /** |
||
178 | * |
||
179 | * @param object $entity |
||
180 | */ |
||
181 | protected function updateEntity(object $entity, ObjectManager $manager): void { |
||
195 | |||
196 | /** |
||
197 | * |
||
198 | * @param object $entity |
||
199 | */ |
||
200 | protected function removeEntity(object $entity, ObjectManager $manager): void { |
||
210 | } |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.