1 | <?php |
||
8 | class RepositoryManager |
||
9 | { |
||
10 | /** |
||
11 | * @var array Registered repositories. |
||
12 | */ |
||
13 | private $repositories = []; |
||
14 | |||
15 | |||
16 | /** |
||
17 | * Create a new repository and add it to the manager. |
||
18 | * |
||
19 | * @param string $model Model class. |
||
20 | * @param array $config Repository configuration. |
||
21 | * |
||
22 | * @return ManagedRepository The created repository. |
||
23 | * |
||
24 | * @throws RepositoryException If the requested repository type is not implemented. |
||
25 | */ |
||
26 | 13 | public function createRepository($model, $config) |
|
49 | |||
50 | |||
51 | /** |
||
52 | * Register a repository with the manager. |
||
53 | * |
||
54 | * @param ManagedRepository $repository Manageable repository. |
||
55 | * |
||
56 | * @throws RepositoryException If the manager already contains a repository for the same model class. |
||
57 | */ |
||
58 | 13 | public function addRepository($repository) |
|
68 | |||
69 | |||
70 | /** |
||
71 | * Get a registered repository by model class. |
||
72 | * |
||
73 | * @param string $class Model class. |
||
74 | * |
||
75 | * @return ManagedRepository|null Matching repository, or null if no repository found. |
||
76 | */ |
||
77 | 13 | public function getByClass($class) |
|
81 | |||
82 | |||
83 | /** |
||
84 | * Inject manager reference into a model capable of receiving it. |
||
85 | * |
||
86 | * @param object $model Model instance. |
||
87 | */ |
||
88 | 10 | public function manageModel($model) |
|
94 | } |
||
95 |