|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* User: jensk |
|
4
|
|
|
* Date: 30-1-2017 |
|
5
|
|
|
* Time: 13:37 |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace CloudControl\Cms\components\cms\configuration; |
|
9
|
|
|
|
|
10
|
|
|
use CloudControl\Cms\cc\Request; |
|
11
|
|
|
use CloudControl\Cms\components\cms\CmsConstants; |
|
12
|
|
|
use CloudControl\Cms\components\cms\CmsRouting; |
|
13
|
|
|
use CloudControl\Cms\components\CmsComponent; |
|
14
|
|
|
|
|
15
|
|
|
class ApplicationComponentRouting extends CmsRouting |
|
16
|
|
|
{ |
|
17
|
|
|
protected static $routes = array( |
|
18
|
|
|
'/configuration/application-components' => 'overviewRoute', |
|
19
|
|
|
'/configuration/application-components/new' => 'newRoute', |
|
20
|
|
|
'/configuration/application-components/edit' => 'editRoute', |
|
21
|
|
|
'/configuration/application-components/delete' => 'deleteRoute', |
|
22
|
|
|
); |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* CmsRouting constructor. |
|
26
|
|
|
* |
|
27
|
|
|
* @param Request $request |
|
28
|
|
|
* @param string $relativeCmsUri |
|
29
|
|
|
* @param CmsComponent $cmsComponent |
|
30
|
|
|
* @throws \Exception |
|
31
|
|
|
*/ |
|
32
|
|
|
public function __construct(Request $request, $relativeCmsUri, CmsComponent $cmsComponent) |
|
33
|
|
|
{ |
|
34
|
|
|
$this->doRouting($request, $relativeCmsUri, $cmsComponent); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @param $request |
|
39
|
|
|
* @param CmsComponent $cmsComponent |
|
40
|
|
|
*/ |
|
41
|
|
|
protected function overviewRoute($request, $cmsComponent) |
|
|
|
|
|
|
42
|
|
|
{ |
|
43
|
|
|
$cmsComponent->subTemplate = 'configuration/application-components'; |
|
44
|
|
|
$cmsComponent->setParameter(CmsConstants::PARAMETER_MAIN_NAV_CLASS, CmsConstants::PARAMETER_CONFIGURATION); |
|
45
|
|
|
$cmsComponent->setParameter(CmsConstants::PARAMETER_APPLICATION_COMPONENTS, |
|
46
|
|
|
$cmsComponent->storage->getApplicationComponents()->getApplicationComponents()); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @param Request $request |
|
51
|
|
|
* @param CmsComponent $cmsComponent |
|
52
|
|
|
*/ |
|
53
|
|
|
protected function newRoute($request, $cmsComponent) |
|
54
|
|
|
{ |
|
55
|
|
|
$cmsComponent->subTemplate = 'configuration/application-components-form'; |
|
56
|
|
|
$cmsComponent->setParameter(CmsConstants::PARAMETER_MAIN_NAV_CLASS, CmsConstants::PARAMETER_CONFIGURATION); |
|
57
|
|
|
if (isset($request::$post[CmsConstants::POST_PARAMETER_TITLE])) { |
|
58
|
|
|
$cmsComponent->storage->getApplicationComponents()->addApplicationComponent($request::$post); |
|
59
|
|
|
header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsConstants::PARAMETER_CMS_PREFIX) . '/configuration/application-components'); |
|
60
|
|
|
exit; |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @param Request $request |
|
66
|
|
|
* @param CmsComponent $cmsComponent |
|
67
|
|
|
*/ |
|
68
|
|
|
protected function editRoute($request, $cmsComponent) |
|
69
|
|
|
{ |
|
70
|
|
|
$cmsComponent->subTemplate = 'configuration/application-components-form'; |
|
71
|
|
|
$cmsComponent->setParameter(CmsConstants::PARAMETER_MAIN_NAV_CLASS, CmsConstants::PARAMETER_CONFIGURATION); |
|
72
|
|
|
$applicationComponent = $cmsComponent->storage->getApplicationComponents()->getApplicationComponentBySlug($request::$get[CmsConstants::GET_PARAMETER_SLUG]); |
|
73
|
|
|
if (isset($request::$post[CmsConstants::POST_PARAMETER_TITLE])) { |
|
74
|
|
|
$cmsComponent->storage->getApplicationComponents()->saveApplicationComponent($request::$get[CmsConstants::GET_PARAMETER_SLUG], |
|
75
|
|
|
$request::$post); |
|
76
|
|
|
header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsConstants::PARAMETER_CMS_PREFIX) . '/configuration/application-components'); |
|
77
|
|
|
exit; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
$cmsComponent->setParameter(CmsConstants::PARAMETER_APPLICATION_COMPONENT, $applicationComponent); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @param Request $request |
|
85
|
|
|
* @param CmsComponent $cmsComponent |
|
86
|
|
|
*/ |
|
87
|
|
|
protected function deleteRoute($request, $cmsComponent) |
|
88
|
|
|
{ |
|
89
|
|
|
$cmsComponent->storage->getApplicationComponents()->deleteApplicationComponentBySlug($request::$get[CmsConstants::GET_PARAMETER_SLUG]); |
|
90
|
|
|
header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsConstants::PARAMETER_CMS_PREFIX) . '/configuration/application-components'); |
|
91
|
|
|
exit; |
|
92
|
|
|
} |
|
93
|
|
|
} |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.