1 | <?php |
||
49 | class Repository implements RepositoryInterface |
||
50 | { |
||
51 | /** |
||
52 | * Apparat base URL |
||
53 | * |
||
54 | * @var string |
||
55 | */ |
||
56 | protected $url = null; |
||
57 | /** |
||
58 | * Adapter strategy |
||
59 | * |
||
60 | * @var AdapterStrategyInterface |
||
61 | */ |
||
62 | protected $adapterStrategy = null; |
||
63 | /** |
||
64 | * Instance specific object cache |
||
65 | * |
||
66 | * @var array |
||
67 | */ |
||
68 | protected $objectCache = []; |
||
69 | |||
70 | /******************************************************************************* |
||
71 | * PUBLIC METHODS |
||
72 | *******************************************************************************/ |
||
73 | |||
74 | /** |
||
75 | * Repository constructor |
||
76 | * |
||
77 | * @param string $url Apparat base URL |
||
78 | * @param array $config Adapter strategy configuration |
||
79 | */ |
||
80 | 12 | public function __construct( |
|
87 | |||
88 | /** |
||
89 | * Initialize the repository |
||
90 | * |
||
91 | * @return void |
||
92 | */ |
||
93 | public function initialize() |
||
97 | |||
98 | /** |
||
99 | * Find objects by selector |
||
100 | * |
||
101 | * @param SelectorInterface $selector Object selector |
||
102 | * @return Collection Object collection |
||
103 | */ |
||
104 | 7 | public function findObjects(SelectorInterface $selector) |
|
108 | |||
109 | /** |
||
110 | * Add an object to the repository |
||
111 | * |
||
112 | * @param ObjectInterface $object Object |
||
113 | * @return boolean Success |
||
114 | */ |
||
115 | public function addObject(ObjectInterface $object) |
||
119 | |||
120 | /** |
||
121 | * Delete and object from the repository |
||
122 | * |
||
123 | * @param ObjectInterface $object Object |
||
124 | * @return boolean Success |
||
125 | */ |
||
126 | public function deleteObject(ObjectInterface $object) |
||
130 | |||
131 | /** |
||
132 | * Update an object in the repository |
||
133 | * |
||
134 | * @param ObjectInterface $object Object |
||
135 | * @return bool Success |
||
136 | */ |
||
137 | public function updateObject(ObjectInterface $object) |
||
141 | |||
142 | /** |
||
143 | * Load an object from this repository |
||
144 | * |
||
145 | * @param PathInterface $path Object path |
||
146 | * @return ObjectInterface Object |
||
147 | */ |
||
148 | 16 | public function loadObject(PathInterface $path) |
|
160 | |||
161 | /** |
||
162 | * Return the repository's adapter strategy |
||
163 | * |
||
164 | * @return AdapterStrategyInterface Adapter strategy |
||
165 | */ |
||
166 | 6 | public function getAdapterStrategy() |
|
170 | |||
171 | /** |
||
172 | * Return the repository URL (relative to Apparat base URL) |
||
173 | * |
||
174 | * @return string Repository URL |
||
175 | */ |
||
176 | 2 | public function getUrl() |
|
180 | |||
181 | /** |
||
182 | * Return the repository size (number of objects in the repository) |
||
183 | * |
||
184 | * @return int Repository size |
||
185 | */ |
||
186 | 1 | public function getSize() |
|
190 | } |
||
191 |