1 | <?php |
||
52 | class Repository implements RepositoryInterface |
||
53 | { |
||
54 | /** |
||
55 | * Apparat base URL |
||
56 | * |
||
57 | * @var string |
||
58 | */ |
||
59 | protected $url = null; |
||
60 | /** |
||
61 | * Adapter strategy |
||
62 | * |
||
63 | * @var AdapterStrategyInterface |
||
64 | */ |
||
65 | protected $adapterStrategy = null; |
||
66 | |||
67 | /******************************************************************************* |
||
68 | * PUBLIC METHODS |
||
69 | *******************************************************************************/ |
||
70 | |||
71 | /** |
||
72 | * Repository constructor |
||
73 | * |
||
74 | * @param string $url Apparat base URL |
||
75 | * @param array $config Adapter strategy configuration |
||
76 | */ |
||
77 | 14 | public function __construct( |
|
84 | |||
85 | /** |
||
86 | * Initialize the repository |
||
87 | * |
||
88 | * @return void |
||
89 | */ |
||
90 | public function initialize() |
||
94 | |||
95 | /** |
||
96 | * Find objects by selector |
||
97 | * |
||
98 | * @param SelectorInterface $selector Object selector |
||
99 | * @return Collection Object collection |
||
100 | */ |
||
101 | 8 | public function findObjects(SelectorInterface $selector) |
|
105 | |||
106 | /** |
||
107 | * Create an object and add it to the repository |
||
108 | * |
||
109 | * @param string|Type $type Object type |
||
110 | * @param string $payload Object payload |
||
111 | * @param array $propertyData Object property data |
||
112 | * @return ObjectInterface Object |
||
113 | */ |
||
114 | 1 | public function createObject($type, $payload = '', array $propertyData = []) |
|
128 | |||
129 | /** |
||
130 | * Delete and object from the repository |
||
131 | * |
||
132 | * @param ObjectInterface $object Object |
||
133 | * @return boolean Success |
||
134 | */ |
||
135 | public function deleteObject(ObjectInterface $object) |
||
139 | |||
140 | /** |
||
141 | * Update an object in the repository |
||
142 | * |
||
143 | * @param ObjectInterface $object Object |
||
144 | * @return bool Success |
||
145 | */ |
||
146 | public function updateObject(ObjectInterface $object) |
||
150 | |||
151 | /** |
||
152 | * Load an object from this repository |
||
153 | * |
||
154 | * @param PathInterface $path Object path |
||
155 | * @return ObjectInterface Object |
||
156 | */ |
||
157 | 16 | public function loadObject(PathInterface $path) |
|
168 | |||
169 | /** |
||
170 | * Return the repository's adapter strategy |
||
171 | * |
||
172 | * @return AdapterStrategyInterface Adapter strategy |
||
173 | */ |
||
174 | 17 | public function getAdapterStrategy() |
|
178 | |||
179 | /** |
||
180 | * Return the repository URL (relative to Apparat base URL) |
||
181 | * |
||
182 | * @return string Repository URL |
||
183 | */ |
||
184 | 11 | public function getUrl() |
|
188 | |||
189 | /** |
||
190 | * Return the repository size (number of objects in the repository) |
||
191 | * |
||
192 | * @return int Repository size |
||
193 | */ |
||
194 | 1 | public function getSize() |
|
198 | } |
||
199 |