public function postUpdate(LifecycleEventArgs $args)
 {
     $entity = $args->getEntity();
     if ($this->indexer->isIndexable($entity) && $this->indexer->isRealtime($entity)) {
         $this->indexer->indexEntity($entity);
     }
 }
Example #2
0
 public function testBatchUpdate()
 {
     $s = new Entity\TestBatchUpdate();
     $s->setContent('Lorem');
     $this->em->persist($s);
     $this->em->flush();
     $this->indexer->indexEntities($this->em, 'Qimnet\\SolrClientTestBundle\\Entity\\TestBatchUpdate');
     $query = new \SolrQuery();
     $query->setQuery("id:" . $s->getSolrId());
     $response = $this->client->query($query)->getResponse();
     $this->assertEquals(1, $response->response->numFound);
     $s->setContent('Ipsum');
     $this->em->persist($s);
     $this->em->flush();
     $this->indexer->indexEntities($this->em, 'Qimnet\\SolrClientTestBundle\\Entity\\TestBatchUpdate');
     $query = new \SolrQuery();
     $query->setQuery("content:Ipsum");
     $response = $this->client->query($query)->getResponse();
     $this->assertGreaterThanOrEqual(1, $response->response->numFound);
     $query = new \SolrQuery();
     $query->setQuery("id:" . $s->getSolrId());
     $this->em->remove($s);
     $this->em->flush();
     $response = $this->client->query($query)->getResponse();
     $this->assertEquals(0, $response->response->numFound);
 }