/** * @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) { } }
/** * {@inheritdoc} */ public function findAll() { $mapper = $this->solr->getMapper(); $mapper->setMappingCommand($this->solr->getCommandFactory()->get('all')); $metaInformation = $this->solr->getMetaFactory()->loadInformation($this->entity); $document = $mapper->toDocument($metaInformation); if (null === $document) { return null; } $document->removeField('id'); $query = new FindByDocumentNameQuery(); $query->setDocument($document); $query->setEntity($this->entity); $query->setSolr($this->solr); $query->setHydrationMode($this->hydrationMode); return $this->solr->query($query); }
/** * {@inheritdoc} */ public function findOneBy(array $args) { $metaInformation = $this->solr->getMetaFactory()->loadInformation($this->entity); $query = $this->solr->createQuery($this->entity); $query->setHydrationMode($this->hydrationMode); $query->setRows(1); $query->setUseAndOperator(true); $query->addSearchTerm('id', $metaInformation->getDocumentName() . '_*'); $query->setQueryDefaultField('id'); $helper = $query->getHelper(); foreach ($args as $fieldName => $fieldValue) { $fieldValue = $helper->escapeTerm($fieldValue); $query->addSearchTerm($fieldName, $fieldValue); } $found = $this->solr->query($query); return array_pop($found); }