|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Doctrine Bundle |
|
5
|
|
|
* |
|
6
|
|
|
* The code was originally distributed inside the Symfony framework. |
|
7
|
|
|
* |
|
8
|
|
|
* (c) Fabien Potencier <[email protected]> |
|
9
|
|
|
* (c) Doctrine Project, Benjamin Eberlei <[email protected]> |
|
10
|
|
|
* |
|
11
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
12
|
|
|
* file that was distributed with this source code. |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
namespace Doctrine\Bundle\DoctrineBundle\Repository; |
|
16
|
|
|
|
|
17
|
|
|
use Doctrine\Common\Collections\Criteria; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* A helpful trait when creating your own repository. |
|
21
|
|
|
* |
|
22
|
|
|
* @author Ryan Weaver <[email protected]> |
|
23
|
|
|
*/ |
|
24
|
|
|
trait RepositoryTrait |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* {@inheritDoc} |
|
28
|
|
|
*/ |
|
29
|
|
|
public function createQueryBuilder($alias, $indexBy = null) |
|
|
|
|
|
|
30
|
|
|
{ |
|
31
|
|
|
return $this->getEntityRepository()->createQueryBuilder($alias, $indexBy); |
|
|
|
|
|
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* {@inheritDoc} |
|
36
|
|
|
*/ |
|
37
|
|
|
public function createResultSetMappingBuilder($alias) |
|
|
|
|
|
|
38
|
|
|
{ |
|
39
|
|
|
return $this->getEntityRepository()->createResultSetMappingBuilder($alias); |
|
|
|
|
|
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* {@inheritDoc} |
|
44
|
|
|
*/ |
|
45
|
|
|
public function createNamedQuery($queryName) |
|
|
|
|
|
|
46
|
|
|
{ |
|
47
|
|
|
return $this->getEntityRepository()->createNamedQuery($queryName); |
|
|
|
|
|
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* {@inheritDoc} |
|
52
|
|
|
*/ |
|
53
|
|
|
public function createNativeNamedQuery($queryName) |
|
|
|
|
|
|
54
|
|
|
{ |
|
55
|
|
|
return $this->getEntityRepository()->createNativeNamedQuery($queryName); |
|
|
|
|
|
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* {@inheritDoc} |
|
60
|
|
|
*/ |
|
61
|
|
|
public function clear() |
|
62
|
|
|
{ |
|
63
|
|
|
$this->getEntityRepository()->clear(); |
|
|
|
|
|
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* {@inheritDoc} |
|
68
|
|
|
*/ |
|
69
|
|
|
public function matching(Criteria $criteria) |
|
|
|
|
|
|
70
|
|
|
{ |
|
71
|
|
|
return $this->getEntityRepository()->matching($criteria); |
|
|
|
|
|
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* {@inheritDoc} |
|
76
|
|
|
*/ |
|
77
|
|
|
public function find($id) |
|
|
|
|
|
|
78
|
|
|
{ |
|
79
|
|
|
return $this->getEntityRepository()->find($id); |
|
|
|
|
|
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* {@inheritDoc} |
|
84
|
|
|
*/ |
|
85
|
|
|
public function findAll() |
|
|
|
|
|
|
86
|
|
|
{ |
|
87
|
|
|
return $this->getEntityRepository()->findAll(); |
|
|
|
|
|
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* {@inheritDoc} |
|
92
|
|
|
*/ |
|
93
|
|
|
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) |
|
|
|
|
|
|
94
|
|
|
{ |
|
95
|
|
|
return $this->getEntityRepository()->findBy($criteria, $orderBy, $limit, $offset); |
|
|
|
|
|
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* {@inheritDoc} |
|
100
|
|
|
*/ |
|
101
|
|
|
public function findOneBy(array $criteria) |
|
|
|
|
|
|
102
|
|
|
{ |
|
103
|
|
|
return $this->getEntityRepository()->findOneBy($criteria); |
|
|
|
|
|
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
public function getClassName() |
|
|
|
|
|
|
107
|
|
|
{ |
|
108
|
|
|
return $this->getEntityRepository()->getClassName(); |
|
|
|
|
|
|
109
|
|
|
} |
|
110
|
|
|
} |
|
111
|
|
|
|
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@returnannotation as described here.