|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace XApi\Repository\Doctrine\Test; |
| 4 | + |
| 5 | +use Doctrine\Common\Persistence\ObjectManager; |
| 6 | +use Xabbuh\XApi\Model\Actor; |
| 7 | +use Xabbuh\XApi\Model\Statement; |
| 8 | +use Xabbuh\XApi\Model\StatementId; |
| 9 | +use Xabbuh\XApi\Model\StatementsFilter; |
| 10 | +use XApi\Repository\Api\StatementRepositoryInterface; |
| 11 | + |
| 12 | +/** |
| 13 | + * Statement repository clearing the object manager between read and write operations. |
| 14 | + * |
| 15 | + * @author Christian Flothmann <[email protected]> |
| 16 | + */ |
| 17 | +final class StatementRepository implements StatementRepositoryInterface |
| 18 | +{ |
| 19 | + private $repository; |
| 20 | + private $objectManager; |
| 21 | + |
| 22 | + public function __construct(StatementRepositoryInterface $repository, ObjectManager $objectManager) |
| 23 | + { |
| 24 | + $this->repository = $repository; |
| 25 | + $this->objectManager = $objectManager; |
| 26 | + } |
| 27 | + |
| 28 | + public function findStatementById(StatementId $statementId, Actor $authority = null) |
| 29 | + { |
| 30 | + $statement = $this->repository->findStatementById($statementId, $authority); |
| 31 | + $this->objectManager->clear(); |
| 32 | + |
| 33 | + return $statement; |
| 34 | + } |
| 35 | + |
| 36 | + public function findVoidedStatementById(StatementId $voidedStatementId, Actor $authority = null) |
| 37 | + { |
| 38 | + $statement = $this->findVoidedStatementById($voidedStatementId, $authority); |
| 39 | + $this->objectManager->clear(); |
| 40 | + |
| 41 | + return $statement; |
| 42 | + } |
| 43 | + |
| 44 | + public function findStatementsBy(StatementsFilter $criteria, Actor $authority = null) |
| 45 | + { |
| 46 | + $statements = $this->findStatementsBy($criteria, $authority); |
| 47 | + $this->objectManager->clear(); |
| 48 | + |
| 49 | + return $statements; |
| 50 | + } |
| 51 | + |
| 52 | + public function storeStatement(Statement $statement, $flush = true) |
| 53 | + { |
| 54 | + $this->repository->storeStatement($statement); |
| 55 | + $this->objectManager->clear(); |
| 56 | + } |
| 57 | +} |
0 commit comments