コード例 #1
0
 /**
  * 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;
 }
コード例 #2
0
 /**
  * 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.');
 }
コード例 #3
0
ファイル: Crud.php プロジェクト: gitter-badger/ApiBundle
 /**
  * {@inheritdoc}
  */
 public function read(Repository $repository, $id)
 {
     return $repository->find($id, Repository::RESULTS_ARRAY);
 }
コード例 #4
0
ファイル: Crud.php プロジェクト: trandangtri/ApiBundle
 /**
  * {@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()]);
 }