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 | * Instance specific object cache |
||
68 | * |
||
69 | * @var array |
||
70 | */ |
||
71 | protected $objectCache = []; |
||
72 | |||
73 | /******************************************************************************* |
||
74 | * PUBLIC METHODS |
||
75 | *******************************************************************************/ |
||
76 | |||
77 | /** |
||
78 | * Repository constructor |
||
79 | * |
||
80 | * @param string $url Apparat base URL |
||
81 | * @param array $config Adapter strategy configuration |
||
82 | */ |
||
83 | 15 | public function __construct( |
|
90 | |||
91 | /** |
||
92 | * Initialize the repository |
||
93 | * |
||
94 | * @return void |
||
95 | */ |
||
96 | public function initialize() |
||
100 | |||
101 | /** |
||
102 | * Find objects by selector |
||
103 | * |
||
104 | * @param SelectorInterface $selector Object selector |
||
105 | * @return Collection Object collection |
||
106 | */ |
||
107 | 7 | public function findObjects(SelectorInterface $selector) |
|
111 | |||
112 | /** |
||
113 | * Create an object and add it to the repository |
||
114 | * |
||
115 | * @param string|Type $type Object type |
||
116 | * @param string $payload Object payload |
||
117 | * @param array $propertyData Object property data |
||
118 | * @return ObjectInterface Object |
||
119 | */ |
||
120 | 1 | public function createObject($type, $payload = '', array $propertyData = []) |
|
132 | |||
133 | /** |
||
134 | * Delete and object from the repository |
||
135 | * |
||
136 | * @param ObjectInterface $object Object |
||
137 | * @return boolean Success |
||
138 | */ |
||
139 | public function deleteObject(ObjectInterface $object) |
||
143 | |||
144 | /** |
||
145 | * Update an object in the repository |
||
146 | * |
||
147 | * @param ObjectInterface $object Object |
||
148 | * @return bool Success |
||
149 | */ |
||
150 | public function updateObject(ObjectInterface $object) |
||
154 | |||
155 | /** |
||
156 | * Load an object from this repository |
||
157 | * |
||
158 | * @param PathInterface $path Object path |
||
159 | * @return ObjectInterface Object |
||
160 | */ |
||
161 | 16 | public function loadObject(PathInterface $path) |
|
177 | |||
178 | /** |
||
179 | * Return the repository's adapter strategy |
||
180 | * |
||
181 | * @return AdapterStrategyInterface Adapter strategy |
||
182 | */ |
||
183 | 7 | public function getAdapterStrategy() |
|
187 | |||
188 | /** |
||
189 | * Return the repository URL (relative to Apparat base URL) |
||
190 | * |
||
191 | * @return string Repository URL |
||
192 | */ |
||
193 | 2 | public function getUrl() |
|
197 | |||
198 | /** |
||
199 | * Return the repository size (number of objects in the repository) |
||
200 | * |
||
201 | * @return int Repository size |
||
202 | */ |
||
203 | 1 | public function getSize() |
|
207 | } |
||
208 |