1 | <?php |
||
10 | class DefaultRepositoryFactory implements RepositoryFactory |
||
11 | { |
||
12 | /** |
||
13 | * The list of DocumentRepository instances. |
||
14 | * |
||
15 | * @var array<\Doctrine\Common\Persistence\ObjectRepository> |
||
16 | */ |
||
17 | private $repositoryList = array(); |
||
18 | |||
19 | /** |
||
20 | * {@inheritdoc} |
||
21 | */ |
||
22 | 2 | public function getRepository(DocumentManager $documentManager, $documentName) |
|
23 | { |
||
24 | 2 | $documentName = ltrim($documentName, '\\'); |
|
25 | |||
26 | 2 | if (isset($this->repositoryList[$documentName])) { |
|
27 | return $this->repositoryList[$documentName]; |
||
28 | } |
||
29 | |||
30 | 2 | $repository = $this->createRepository($documentManager, $documentName); |
|
31 | |||
32 | 2 | $this->repositoryList[$documentName] = $repository; |
|
33 | |||
34 | 2 | return $repository; |
|
35 | } |
||
36 | |||
37 | /** |
||
38 | * Create a new repository instance for a document class. |
||
39 | * |
||
40 | * @param DocumentManager $documentManager The DocumentManager instance. |
||
41 | * @param string $documentName The name of the document. |
||
42 | * |
||
43 | * @return \Doctrine\Common\Persistence\ObjectRepository |
||
44 | */ |
||
45 | 2 | protected function createRepository(DocumentManager $documentManager, $documentName) |
|
57 | } |