Symfony2 FOSElasticaBundle update index for all entities related to the entity updated

前端 未结 7 1446
無奈伤痛
無奈伤痛 2020-12-30 06:07

I\'m using FOSElasticaBundle and Doctrine in my project, and my code works for the selective index update using the Doctrine lifecycle events. The issue I come up against is

7条回答
  •  有刺的猬
    2020-12-30 06:18

    Sorry, i can not comment under your answer but something is missing in the solution. You have to override preRemove too.

    public function preRemove(\Doctrine\Common\EventArgs $eventArgs)
    {
        $entity = $eventArgs->getEntity();
    
    
    
        if ($entity instanceof $this->objectClass) {
    
            $this->scheduleForDeletion($entity);
            $this->initialiseJob();
            foreach ($entity->getJobOpenings() as $job) {
                    $this->objectPersisterJob->replaceOne($job);
                }
        }
    }
    

提交回复
热议问题