1 | <?php |
||
19 | class DoctrineListener implements EventSubscriber { |
||
20 | |||
21 | /** |
||
22 | * |
||
23 | * @var EntityToDocumentMapperInterface |
||
24 | */ |
||
25 | protected $entityToDocumentMapper; |
||
26 | |||
27 | /** |
||
28 | * |
||
29 | * @var SearchService |
||
30 | */ |
||
31 | protected $searchService; |
||
32 | |||
33 | public function getSubscribedEvents() { |
||
40 | |||
41 | /** |
||
42 | * Constructor |
||
43 | * |
||
44 | * @param SearchService $searchService |
||
45 | */ |
||
46 | public function __construct(EntityToDocumentMapperInterface $entityToDocumentMapper, SearchService $searchService) { |
||
50 | |||
51 | /** |
||
52 | * Index the entity after it is persisted for the first time |
||
53 | * |
||
54 | * @param LifecycleEventArgs $args |
||
55 | */ |
||
56 | public function postPersist(LifecycleEventArgs $args) { |
||
59 | |||
60 | /** |
||
61 | * Removes the entity from the index when it marked for deletion |
||
62 | * |
||
63 | * @param LifecycleEventArgs $args |
||
64 | */ |
||
65 | public function preRemove(LifecycleEventArgs $args) { |
||
68 | |||
69 | /** |
||
70 | * Updates the entity in the index after it is updated |
||
71 | * |
||
72 | * @param LifecycleEventArgs $args |
||
73 | */ |
||
74 | public function postUpdate(LifecycleEventArgs $args) { |
||
77 | |||
78 | /** |
||
79 | * |
||
80 | * @return EntityToDocumentMapperInterface |
||
81 | */ |
||
82 | protected function getEntityToDocumentMapper() { |
||
85 | |||
86 | /** |
||
87 | * |
||
88 | * @return SearchService |
||
89 | */ |
||
90 | protected function getSearchService(ObjectManager $manager) { |
||
94 | |||
95 | /** |
||
96 | * |
||
97 | * @param object $entity |
||
98 | */ |
||
99 | protected function updateEntity($entity, ObjectManager $manager) { |
||
105 | |||
106 | /** |
||
107 | * |
||
108 | * @param object $entity |
||
109 | */ |
||
110 | protected function removeEntity($entity, ObjectManager $manager) { |
||
116 | } |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.