/** * Returns translation from elasticsearch. * * @param string $id * * @return object * * @throws BadRequestHttpException */ private function getTranslation($id) { try { $document = $this->repository->find($id); } catch (Missing404Exception $e) { $document = null; } if ($document === null) { throw new BadRequestHttpException('Invalid translation Id.'); } return $document; }
/** * Tests cloning documents. */ public function testCloningDocuments() { $manager = $this->repository->getManager(); $document = new ProductDocument(); $document->setId('tuna_id'); $document->title = 'tuna'; $manager->persist($document); $manager->commit(); $document = $this->repository->find('tuna_id'); $clone = clone $document; $this->assertNull($clone->getId(), 'Id should be null\'ed.'); $manager->persist($clone); $manager->commit(); $search = $this->repository->createSearch()->addQuery(new TermQuery('title', 'tuna')); $this->assertCount(2, $this->repository->execute($search), '2 Results should be found.'); }
/** * {@inheritdoc} */ public function read(Repository $repository, $id) { return $repository->find($id, Repository::RESULTS_ARRAY); }
/** * {@inheritdoc} */ public function read(Repository $repository, $id) { return $repository->find($id); }
public function project($event) { $user = $this->repository->find($event->userId()); $this->repository->update($event->userId(), ['points' => $user->getPoints() + $event->earnedPoints()]); }