1 | <?php |
||
51 | class PersistenceService implements PersistenceServiceInterface |
||
52 | { |
||
53 | /** |
||
54 | * Persistence adapter factory |
||
55 | * |
||
56 | * @var PersistenceAdapterFactoryInterface |
||
57 | */ |
||
58 | protected $persistenceAdapterFactory; |
||
59 | /** |
||
60 | * Webservers scheduled for reload |
||
61 | * |
||
62 | * @var array |
||
63 | */ |
||
64 | protected $reloadWebserver = []; |
||
65 | /** |
||
66 | * PHP-Restart flag |
||
67 | * |
||
68 | * @var bool |
||
69 | */ |
||
70 | protected $reloadPhp = false; |
||
71 | |||
72 | /** |
||
73 | * Constructor |
||
74 | * |
||
75 | * @param PersistenceAdapterFactoryInterface $persistenceAdapterFactory Persistence adapter factory |
||
76 | */ |
||
77 | public function __construct(PersistenceAdapterFactoryInterface $persistenceAdapterFactory) |
||
81 | |||
82 | /** |
||
83 | * Create an account |
||
84 | * |
||
85 | * @param AccountInterface $account Account |
||
86 | * @return void |
||
87 | */ |
||
88 | public function createAccount(AccountInterface $account) |
||
91 | |||
92 | /** |
||
93 | * Delete an account |
||
94 | * |
||
95 | * @param AccountInterface $account Account |
||
96 | * @return void |
||
97 | */ |
||
98 | public function deleteAccount(AccountInterface $account) |
||
106 | |||
107 | /** |
||
108 | * Enable an account |
||
109 | * |
||
110 | * @param AccountInterface $account Account |
||
111 | * @return void |
||
112 | */ |
||
113 | public function enableAccount(AccountInterface $account) |
||
121 | |||
122 | /** |
||
123 | * Disable an account |
||
124 | * |
||
125 | * @param AccountInterface $account Account |
||
126 | * @return void |
||
127 | */ |
||
128 | public function disableAccount(AccountInterface $account) |
||
136 | |||
137 | /** |
||
138 | * Rename an account |
||
139 | * |
||
140 | * @param AccountInterface $account Account |
||
141 | * @return void |
||
142 | */ |
||
143 | public function renameAccount(AccountInterface $account) |
||
148 | |||
149 | /** |
||
150 | * Create a virtual host |
||
151 | * |
||
152 | * @param AccountInterface $account Account |
||
153 | * @param VhostInterface $vhost Virtual host |
||
154 | * @return void |
||
155 | */ |
||
156 | public function createVhost(AccountInterface $account, VhostInterface $vhost) |
||
173 | |||
174 | /** |
||
175 | * Delete a virtual host |
||
176 | * |
||
177 | * @param AccountInterface $account Account |
||
178 | * @param VhostInterface $vhost Virtual host |
||
179 | * @return void |
||
180 | */ |
||
181 | public function deleteVhost(AccountInterface $account, VhostInterface $vhost) |
||
192 | |||
193 | /** |
||
194 | * Enable a virtual host |
||
195 | * |
||
196 | * @param AccountInterface $account Account |
||
197 | * @param VhostInterface $vhost Virtual host |
||
198 | * @return void |
||
199 | * @throws \RuntimeException If the virtual host directory doesn't exist yet |
||
200 | * @throws \RuntimeException If the virtual host is already enabled but cannot be renewed |
||
201 | */ |
||
202 | public function enableVhost(AccountInterface $account, VhostInterface $vhost) |
||
238 | |||
239 | /** |
||
240 | * Disable a virtual host |
||
241 | * |
||
242 | * @param AccountInterface $account Account |
||
243 | * @param VhostInterface $vhost Virtual host |
||
244 | * @return void |
||
245 | */ |
||
246 | public function disableVhost(AccountInterface $account, VhostInterface $vhost) |
||
262 | |||
263 | /** |
||
264 | * Redirect a virtual host |
||
265 | * |
||
266 | * @param AccountInterface $account Account |
||
267 | * @param VhostInterface $vhost Virtual host |
||
268 | * @return void |
||
269 | */ |
||
270 | public function redirectVhost(AccountInterface $account, VhostInterface $vhost) |
||
278 | |||
279 | /** |
||
280 | * Configure the PHP version of a virtual host |
||
281 | * |
||
282 | * @param AccountInterface $account Account |
||
283 | * @param VhostInterface $vhost Virtual host |
||
284 | * @return void |
||
285 | * @throws \RuntimeException If the previous PHP configuration cannot be removed |
||
286 | */ |
||
287 | public function phpVhost(AccountInterface $account, VhostInterface $vhost) |
||
312 | |||
313 | /** |
||
314 | * Configure a protocol based port for a virtual host |
||
315 | * |
||
316 | * @param AccountInterface $account Account |
||
317 | * @param VhostInterface $vhost Virtual host |
||
318 | * @return void |
||
319 | */ |
||
320 | public function portVhost(AccountInterface $account, VhostInterface $vhost) |
||
330 | |||
331 | /** |
||
332 | * Add a secondary domain to a virtual host |
||
333 | * |
||
334 | * @param AccountInterface $account Account |
||
335 | * @param VhostInterface $vhost Virtual host |
||
336 | * @return void |
||
337 | */ |
||
338 | public function domainVhost(AccountInterface $account, VhostInterface $vhost) |
||
348 | |||
349 | /** |
||
350 | * Register a webserver reload |
||
351 | * |
||
352 | * @param string $type Webserver type |
||
353 | */ |
||
354 | protected function registerWebserverReload($type) |
||
358 | |||
359 | /** |
||
360 | * Flag PHP for reloading |
||
361 | */ |
||
362 | protected function registerPhpReload() |
||
366 | |||
367 | /** |
||
368 | * Prepare a directory |
||
369 | * |
||
370 | * @param string $directory Directory |
||
371 | * @return string Prepared directory |
||
372 | */ |
||
373 | protected function prepareDirectory($directory) |
||
380 | |||
381 | /** |
||
382 | * Recursively delete a directory |
||
383 | * |
||
384 | * @param string $directory Directory |
||
385 | * @throws \RuntimeException If a file or directory cannot be deleted |
||
386 | */ |
||
387 | protected function deleteDirectory($directory) |
||
411 | |||
412 | /** |
||
413 | * Persist a virtual host |
||
414 | * |
||
415 | * @param AccountInterface $account Account |
||
416 | * @param VhostInterface $vhost Virtual host |
||
417 | */ |
||
418 | protected function persistVhost(AccountInterface $account, VhostInterface $vhost) |
||
425 | } |
||
426 |