/**
  * @param ConsoleTerminateEvent $event
  */
 public function onConsoleTerminate(ConsoleTerminateEvent $event)
 {
     if ($this->isProcessingRequired($event)) {
         if ($event->getExitCode() === 0) {
             $this->searchEngine->reindex();
         }
         $this->searchListener->setEnabled(true);
     }
 }
예제 #2
0
 /**
  * To make indexation faster do only one flush instead of several
  */
 protected function indexEntities()
 {
     $this->searchEngine->setNeedFlush(false);
     parent::indexEntities();
     $this->searchEngine->flush();
     $this->searchEngine->setNeedFlush(true);
 }
 public function testOnFlushAndPostFlushNotUpdatesIndexWhenNotActive()
 {
     $this->uow->expects($this->once())->method('getScheduledEntityInsertions')->will($this->returnValue(array()));
     $this->uow->expects($this->once())->method('getScheduledEntityUpdates')->will($this->returnValue(array()));
     $this->uow->expects($this->once())->method('getScheduledEntityDeletions')->will($this->returnValue(array()));
     $this->engine->expects($this->never())->method($this->anything());
     $this->entityManager->expects($this->never())->method('flush');
     $this->listener->onFlush($this->onFlushArgs);
     $this->listener->postFlush($this->postFlushArgs);
 }
예제 #4
0
 /**
  * @param bool $realTime
  * @return IndexListener
  */
 protected function createListener($realTime = true)
 {
     $listener = new IndexListener($this->doctrineHelper, $this->searchEngine);
     $listener->setRealTimeUpdate($realTime);
     $listener->setEntitiesConfig($this->entitiesMapping);
     return $listener;
 }
예제 #5
0
 /**
  * @param bool $realTime
  * @return IndexListener
  */
 protected function createListener($realTime = true)
 {
     $listener = new IndexListener($this->doctrineHelper, $this->searchEngine);
     $listener->setRealTimeUpdate($realTime);
     $listener->setEntitiesConfig($this->entitiesMapping);
     $eventDispatcher = $this->getMockBuilder('Symfony\\Component\\EventDispatcher\\EventDispatcher')->disableOriginalConstructor()->getMock();
     $mapperProvider = new SearchMappingProvider($eventDispatcher);
     $mapperProvider->setMappingConfig($this->entitiesMapping);
     $listener->setMappingProvider($mapperProvider);
     return $listener;
 }