1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace CloudControl\Cms\storage { |
4
|
|
|
|
5
|
|
|
use CloudControl\Cms\storage\factories\DocumentFolderFactory; |
6
|
|
|
use CloudControl\Cms\storage\storage\ActivityLogStorage; |
7
|
|
|
use CloudControl\Cms\storage\storage\ApplicationComponentsStorage; |
8
|
|
|
use CloudControl\Cms\storage\storage\BricksStorage; |
9
|
|
|
use CloudControl\Cms\storage\storage\DocumentStorage; |
10
|
|
|
use CloudControl\Cms\storage\storage\DocumentTypesStorage; |
11
|
|
|
use CloudControl\Cms\storage\storage\FilesStorage; |
12
|
|
|
use CloudControl\Cms\storage\storage\ImageSetStorage; |
13
|
|
|
use CloudControl\Cms\storage\storage\ImagesStorage; |
14
|
|
|
use CloudControl\Cms\storage\storage\RedirectsStorage; |
15
|
|
|
use CloudControl\Cms\storage\storage\SitemapStorage; |
16
|
|
|
use CloudControl\Cms\storage\storage\UsersStorage; |
17
|
|
|
use CloudControl\Cms\storage\storage\ValuelistsStorage; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Class JsonStorage |
21
|
|
|
* @package CloudControl\Cms\storage |
22
|
|
|
*/ |
23
|
|
|
class Storage |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* @var SitemapStorage |
27
|
|
|
*/ |
28
|
|
|
protected $sitemap; |
29
|
|
|
/** |
30
|
|
|
* @var ImagesStorage |
31
|
|
|
*/ |
32
|
|
|
protected $images; |
33
|
|
|
/** |
34
|
|
|
* @var ImageSetStorage |
35
|
|
|
*/ |
36
|
|
|
protected $imageSet; |
37
|
|
|
/** |
38
|
|
|
* @var FilesStorage |
39
|
|
|
*/ |
40
|
|
|
protected $files; |
41
|
|
|
/** |
42
|
|
|
* @var UsersStorage |
43
|
|
|
*/ |
44
|
|
|
protected $users; |
45
|
|
|
/** |
46
|
|
|
* @var DocumentTypesStorage |
47
|
|
|
*/ |
48
|
|
|
protected $documentTypes; |
49
|
|
|
/** |
50
|
|
|
* @var BricksStorage |
51
|
|
|
*/ |
52
|
|
|
protected $bricks; |
53
|
|
|
/** |
54
|
|
|
* @var ApplicationComponentsStorage |
55
|
|
|
*/ |
56
|
|
|
protected $applicationComponents; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @var ValuelistsStorage |
60
|
|
|
*/ |
61
|
|
|
protected $valuelists; |
62
|
|
|
/** |
63
|
|
|
* @var DocumentStorage |
64
|
|
|
*/ |
65
|
|
|
protected $documents; |
66
|
|
|
/** |
67
|
|
|
* @var RedirectsStorage |
68
|
|
|
*/ |
69
|
|
|
protected $redirects; |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @var ActivityLogStorage |
73
|
|
|
*/ |
74
|
|
|
protected $activityLog; |
75
|
|
|
/** |
76
|
|
|
* @var String |
77
|
|
|
*/ |
78
|
|
|
protected $imagesDir; |
79
|
|
|
/** |
80
|
|
|
* @var String |
81
|
|
|
*/ |
82
|
|
|
protected $filesDir; |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @var String |
86
|
|
|
*/ |
87
|
|
|
private $storageDir; |
88
|
|
|
/** |
89
|
|
|
* @var Repository |
90
|
|
|
*/ |
91
|
|
|
private $repository; |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* JsonStorage constructor. |
95
|
|
|
* |
96
|
|
|
* @param string $storageDir |
97
|
|
|
* @param $imagesDir |
98
|
|
|
* @param $filesDir |
99
|
|
|
*/ |
100
|
|
|
public function __construct($storageDir, $imagesDir, $filesDir) |
101
|
|
|
{ |
102
|
|
|
$this->storageDir = $storageDir; |
103
|
|
|
$this->imagesDir = $imagesDir; |
104
|
|
|
$this->filesDir = $filesDir; |
105
|
|
|
$this->config(); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* Retrieve the data from the storagepath |
110
|
|
|
* so it can be interacted with |
111
|
|
|
* |
112
|
|
|
* @throws \Exception |
113
|
|
|
*/ |
114
|
|
|
private function config() |
115
|
|
|
{ |
116
|
|
|
$storagePath = $this->storageDir; |
117
|
|
|
if (realpath($storagePath) === false) { |
118
|
|
|
throw new \Exception('Storage doesnt seem to be initialized, consider running composer install to do so.'); |
119
|
|
|
} else { |
120
|
|
|
$this->repository = new Repository($storagePath); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* @return \CloudControl\Cms\storage\storage\UsersStorage |
127
|
|
|
*/ |
128
|
|
|
public function getUsers() |
129
|
|
|
{ |
130
|
|
|
if (!$this->users instanceof UsersStorage) { |
131
|
|
|
$this->users = new UsersStorage($this->repository); |
132
|
|
|
} |
133
|
|
|
return $this->users; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* Get documents |
138
|
|
|
* |
139
|
|
|
* @return DocumentStorage |
140
|
|
|
*/ |
141
|
|
|
public function getDocuments() |
142
|
|
|
{ |
143
|
|
|
if (!$this->documents instanceof DocumentStorage) { |
144
|
|
|
$this->documents = new DocumentStorage($this->repository); |
145
|
|
|
} |
146
|
|
|
return $this->documents; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* @return SitemapStorage |
151
|
|
|
*/ |
152
|
|
|
public function getSitemap() |
153
|
|
|
{ |
154
|
|
|
if (!$this->sitemap instanceof SitemapStorage) { |
155
|
|
|
$this->sitemap = new SitemapStorage($this->repository); |
156
|
|
|
} |
157
|
|
|
return $this->sitemap; |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* Get all images |
162
|
|
|
* |
163
|
|
|
* @return ImagesStorage |
164
|
|
|
*/ |
165
|
|
|
public function getImages() |
166
|
|
|
{ |
167
|
|
|
if (!$this->images instanceof ImagesStorage) { |
168
|
|
|
|
169
|
|
|
$this->images = new ImagesStorage($this->repository, $this->imagesDir); |
170
|
|
|
} |
171
|
|
|
return $this->images; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* Get all files |
176
|
|
|
* |
177
|
|
|
* @return FilesStorage |
178
|
|
|
*/ |
179
|
|
|
public function getFiles() |
180
|
|
|
{ |
181
|
|
|
if (!$this->files instanceof FilesStorage) { |
182
|
|
|
$this->files = new FilesStorage($this->repository, $this->filesDir); |
183
|
|
|
} |
184
|
|
|
return $this->files; |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* @return string |
189
|
|
|
*/ |
190
|
|
|
public function getStorageDir() |
191
|
|
|
{ |
192
|
|
|
return $this->storageDir; |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* @return \PDO |
197
|
|
|
*/ |
198
|
|
|
public function getContentDbHandle() |
199
|
|
|
{ |
200
|
|
|
return $this->repository->getContentDbHandle(); |
|
|
|
|
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* @return DocumentTypesStorage |
205
|
|
|
*/ |
206
|
|
|
public function getDocumentTypes() |
207
|
|
|
{ |
208
|
|
|
if (!$this->documentTypes instanceof DocumentTypesStorage) { |
209
|
|
|
$this->documentTypes = new DocumentTypesStorage($this->repository); |
210
|
|
|
} |
211
|
|
|
return $this->documentTypes; |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
/** |
215
|
|
|
* @return BricksStorage |
216
|
|
|
*/ |
217
|
|
View Code Duplication |
public function getBricks() |
|
|
|
|
218
|
|
|
{ |
219
|
|
|
if (!$this->bricks instanceof BricksStorage) { |
220
|
|
|
$this->bricks = new BricksStorage($this->repository); |
221
|
|
|
} |
222
|
|
|
return $this->bricks; |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
/** |
226
|
|
|
* Get the image set |
227
|
|
|
* |
228
|
|
|
* @return ImageSetStorage |
229
|
|
|
*/ |
230
|
|
View Code Duplication |
public function getImageSet() |
|
|
|
|
231
|
|
|
{ |
232
|
|
|
if (!$this->imageSet instanceof ImageSetStorage) { |
233
|
|
|
$this->imageSet = new ImageSetStorage($this->repository); |
234
|
|
|
} |
235
|
|
|
return $this->imageSet; |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
/** |
239
|
|
|
* @return ApplicationComponentsStorage |
240
|
|
|
*/ |
241
|
|
|
public function getApplicationComponents() |
242
|
|
|
{ |
243
|
|
|
if (!$this->applicationComponents instanceof ApplicationComponentsStorage) { |
244
|
|
|
$this->applicationComponents = new ApplicationComponentsStorage($this->repository); |
245
|
|
|
} |
246
|
|
|
return $this->applicationComponents; |
247
|
|
|
} |
248
|
|
|
|
249
|
|
|
/** |
250
|
|
|
* @return \CloudControl\Cms\storage\Repository |
251
|
|
|
*/ |
252
|
|
|
public function getRepository() |
253
|
|
|
{ |
254
|
|
|
return $this->repository; |
255
|
|
|
} |
256
|
|
|
|
257
|
|
|
/** |
258
|
|
|
* @return \CloudControl\Cms\storage\storage\ValuelistsStorage |
259
|
|
|
*/ |
260
|
|
|
public function getValuelists() |
261
|
|
|
{ |
262
|
|
|
if (!$this->valuelists instanceof ValuelistsStorage) { |
263
|
|
|
$this->valuelists = new ValuelistsStorage($this->repository); |
264
|
|
|
} |
265
|
|
|
return $this->valuelists; |
266
|
|
|
} |
267
|
|
|
|
268
|
|
|
/** |
269
|
|
|
* @return \CloudControl\Cms\storage\storage\RedirectsStorage |
270
|
|
|
*/ |
271
|
|
|
public function getRedirects() |
272
|
|
|
{ |
273
|
|
|
if (!$this->redirects instanceof RedirectsStorage) { |
274
|
|
|
$this->redirects = new RedirectsStorage($this->repository); |
275
|
|
|
} |
276
|
|
|
return $this->redirects; |
277
|
|
|
} |
278
|
|
|
|
279
|
|
|
/** |
280
|
|
|
* @return ActivityLogStorage |
281
|
|
|
*/ |
282
|
|
|
public function getActivityLog() |
283
|
|
|
{ |
284
|
|
|
if (!$this->activityLog instanceof ActivityLogStorage) { |
285
|
|
|
$this->activityLog = new ActivityLogStorage($this->repository); |
286
|
|
|
} |
287
|
|
|
return $this->activityLog; |
288
|
|
|
} |
289
|
|
|
|
290
|
|
|
|
291
|
|
|
} |
292
|
|
|
} |
This check looks for access to methods that are not accessible from the current context.
If you need to make a method accessible to another context you can raise its visibility level in the defining class.