getObject(); if ($entity instanceof SearchableInterface) { $this->searchService->index($entity); } } public function postPersist(LifecycleEventArgs $args) { $entity = $args->getObject(); if ($entity instanceof SearchableInterface) { $this->searchService->index($entity); } } public function preRemove(LifecycleEventArgs $args) { $entity = $args->getObject(); if ($entity instanceof SearchableInterface) { $this->searchService->unIndex($entity); } } }