1 | <?php |
||
40 | class DocumentRepository implements ObjectRepository, Selectable |
||
41 | { |
||
42 | /** |
||
43 | * @var string |
||
44 | */ |
||
45 | protected $documentName; |
||
46 | |||
47 | /** |
||
48 | * @var DocumentManager |
||
49 | */ |
||
50 | protected $dm; |
||
51 | |||
52 | /** |
||
53 | * @var UnitOfWork |
||
54 | */ |
||
55 | protected $uow; |
||
56 | |||
57 | /** |
||
58 | * @var ClassMetadata |
||
59 | */ |
||
60 | protected $class; |
||
61 | |||
62 | /** |
||
63 | * Initializes this instance with the specified document manager, unit of work and |
||
64 | * class metadata. |
||
65 | * |
||
66 | * @param DocumentManager $dm The DocumentManager to use. |
||
67 | * @param UnitOfWork $uow The UnitOfWork to use. |
||
68 | * @param ClassMetadata $classMetadata The class metadata. |
||
69 | */ |
||
70 | 342 | public function __construct(DocumentManager $dm, UnitOfWork $uow, ClassMetadata $classMetadata) |
|
77 | |||
78 | /** |
||
79 | * Creates a new Query\Builder instance that is preconfigured for this document name. |
||
80 | * |
||
81 | * @return Query\Builder $qb |
||
82 | */ |
||
83 | 27 | public function createQueryBuilder() |
|
87 | |||
88 | /** |
||
89 | * Clears the repository, causing all managed documents to become detached. |
||
90 | */ |
||
91 | public function clear() |
||
95 | |||
96 | /** |
||
97 | * Finds a document matching the specified identifier. Optionally a lock mode and |
||
98 | * expected version may be specified. |
||
99 | * |
||
100 | * @param mixed $id Identifier. |
||
101 | * @param int $lockMode Optional. Lock mode; one of the LockMode constants. |
||
102 | * @param int $lockVersion Optional. Expected version. |
||
103 | * @throws Mapping\MappingException |
||
104 | * @throws LockException |
||
105 | * @return object|null The document, if found, otherwise null. |
||
106 | */ |
||
107 | 235 | public function find($id, $lockMode = LockMode::NONE, $lockVersion = null) |
|
152 | |||
153 | /** |
||
154 | * Finds all documents in the repository. |
||
155 | * |
||
156 | * @return array |
||
157 | */ |
||
158 | 10 | public function findAll() |
|
162 | |||
163 | /** |
||
164 | * Finds documents by a set of criteria. |
||
165 | * |
||
166 | * @param array $criteria Query criteria |
||
167 | * @param array $sort Sort array for Cursor::sort() |
||
168 | * @param integer|null $limit Limit for Cursor::limit() |
||
169 | * @param integer|null $skip Skip for Cursor::skip() |
||
170 | * |
||
171 | * @return array |
||
172 | */ |
||
173 | 11 | public function findBy(array $criteria, array $sort = null, $limit = null, $skip = null) |
|
177 | |||
178 | /** |
||
179 | * Finds a single document by a set of criteria. |
||
180 | * |
||
181 | * @param array $criteria |
||
182 | * @return object |
||
183 | */ |
||
184 | 73 | public function findOneBy(array $criteria) |
|
188 | |||
189 | /** |
||
190 | * Adds support for magic finders. |
||
191 | * |
||
192 | * @param string $method |
||
193 | * @param array $arguments |
||
194 | * @throws MongoDBException |
||
195 | * @throws \BadMethodCallException If the method called is an invalid find* method |
||
196 | * or no find* method at all and therefore an invalid |
||
197 | * method call. |
||
198 | * @return array|object The found document/documents. |
||
199 | */ |
||
200 | 10 | public function __call($method, $arguments) |
|
226 | |||
227 | /** |
||
228 | * @return string |
||
229 | */ |
||
230 | public function getDocumentName() |
||
234 | |||
235 | /** |
||
236 | * @return DocumentManager |
||
237 | */ |
||
238 | public function getDocumentManager() |
||
242 | |||
243 | /** |
||
244 | * @return Mapping\ClassMetadata |
||
245 | */ |
||
246 | public function getClassMetadata() |
||
250 | |||
251 | /** |
||
252 | * @return string |
||
253 | */ |
||
254 | public function getClassName() |
||
258 | |||
259 | /** |
||
260 | * Selects all elements from a selectable that match the expression and |
||
261 | * returns a new collection containing these elements. |
||
262 | * |
||
263 | * @see Selectable::matching() |
||
264 | * @param Criteria $criteria |
||
265 | * @return Collection |
||
266 | */ |
||
267 | 4 | public function matching(Criteria $criteria) |
|
292 | |||
293 | 312 | protected function getDocumentPersister() |
|
297 | } |
||
298 |