/** * @param LifecycleEventArgs $args */ public function postUpdate(LifecycleEventArgs $args) { try { $entity = $args->getEntity(); $metaInformation = $this->solr->getMetaFactory()->loadInformation($entity); $entity = EntityHelper::customizeEntity($entity, $metaInformation); $this->solr->updateDocument($entity); EntityHelper::normalizationEntity($entity, $metaInformation); } catch (\RuntimeException $e) { } }
public function testNormalizationEntity() { $id = 2; $repo = $this->entityManager->getRepository("UserBundle:Department"); $department = $repo->find($id); /** @var \SearchBundle\Service\SearchService $solr_search */ $solr_search = $this->container->get('solr_search'); $metaInformation = $solr_search->getMetaFactory()->loadInformation($department); EntityHelper::customizeEntity($department, $metaInformation); EntityHelper::normalizationEntity($department, $metaInformation); $this->assertEquals($id, $department->getId()); }
private function updateRepository($repository, OutputInterface $output) { $entities = $repository->findAll(); if (count($entities) == 0) { $output->writeln('<comment>No entities found for indexing</comment>'); return; } $solr = $this->getContainer()->get('solr.client'); foreach ($entities as $entity) { try { $metaInformation = $solr->getMetaFactory()->loadInformation($entity); $entity = EntityHelper::customizeEntity($entity, $metaInformation); $solr->synchronizeIndex($entity); EntityHelper::normalizationEntity($entity, $metaInformation); } catch (\Exception $e) { } } $results = $this->getContainer()->get('solr.console.command.results'); if ($results->hasErrors()) { $output->writeln('<info>Synchronization finished with errors!</info>'); } else { $output->writeln('<info>Synchronization successful</info>'); } }