Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class UserDependentRepository extends Doctrine\ORM\EntityRepository implements Doctrine\Common\Persistence\ObjectRepository
- {
- public function __construct(Doctrine\ORM\EntityManager $em, Mapping\ClassMetadata $class, Identity $identity)
- {
- $this->repository = new Doctrine\ORM\EntityRepository($em, $class);
- $this->identity = $identity;
- $this->class = $class;
- $this->em = $em;
- }
- public function createQueryBuilder($alias)
- {
- return $this->repository->createQueryBuilder($alias)
- ->where($alias . '.identity = :identity')
- ->setParameter('identity', $this->identity->id);
- }
- public function find($id)
- {
- $id = array_combine($this->class->identifier, (array)$id);
- return $this->repository->findBy($id + array(
- 'identity' => $this->identity->id
- ));
- }
- public function findAll()
- {
- return $this->repository->findBy(array(
- 'identity' => $this->identity->id
- ));
- }
- public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
- {
- return $this->repository->findBy(array(
- 'identity' => $this->identity->id
- ) + $criteria, $orderBy, $limit, $offset);
- }
- public function findOneBy(array $criteria)
- {
- return $this->repository->findBy(array(
- 'identity' => $this->identity->id
- ) + $criteria);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment