1 | <?php |
||
61 | class Server extends \Apparat\Server\Domain\Model\Server |
||
62 | { |
||
63 | /** |
||
64 | * View resources |
||
65 | * |
||
66 | * @var array |
||
67 | */ |
||
68 | protected $viewResources = []; |
||
69 | |||
70 | /** |
||
71 | * Enable the object route for a particular repository |
||
72 | * |
||
73 | * @param string $repositoryPath Repository path |
||
74 | * @param int $enable Enable / disable default actions |
||
75 | */ |
||
76 | 1 | public function enableObjectRoute($repositoryPath = '', $enable = ObjectRoute::ALL) |
|
98 | |||
99 | /** |
||
100 | * Return the enabled object action classes |
||
101 | * |
||
102 | * @param int $enable Enable / disable default actions |
||
103 | * @return array Enabled object action classes |
||
104 | */ |
||
105 | 1 | protected function getEnabledObjectActionClasses($enable) |
|
106 | { |
||
107 | return [ |
||
108 | 1 | ObjectRoute::OBJECT_STR => (ObjectRoute::OBJECT & $enable) ? ObjectAction::class : null, |
|
109 | 1 | ObjectRoute::TYPE_STR => (ObjectRoute::TYPE & $enable) ? TypeAction::class : null, |
|
110 | 1 | ObjectRoute::OBJECTS_STR => (ObjectRoute::OBJECTS & $enable) ? ObjectsAction::class : null, |
|
111 | 1 | ]; |
|
112 | } |
||
113 | |||
114 | /** |
||
115 | * Return the enabled date action classes |
||
116 | * |
||
117 | * @param int $enable Enable / disable default actions |
||
118 | * @param int $datePrecision Date precision |
||
119 | * @return array Enabled date action classes |
||
120 | */ |
||
121 | 1 | protected function getEnabledDateActionClasses($enable, $datePrecision) |
|
122 | { |
||
123 | 1 | return array_slice( |
|
124 | [ |
||
125 | 1 | ObjectRoute::SECOND_STR => (ObjectRoute::SECOND & $enable) ? SecondAction::class : null, |
|
126 | 1 | ObjectRoute::MINUTE_STR => (ObjectRoute::MINUTE & $enable) ? MinuteAction::class : null, |
|
127 | 1 | ObjectRoute::HOUR_STR => (ObjectRoute::HOUR & $enable) ? HourAction::class : null, |
|
128 | 1 | ObjectRoute::DAY_STR => (ObjectRoute::DAY & $enable) ? DayAction::class : null, |
|
129 | 1 | ObjectRoute::MONTH_STR => (ObjectRoute::MONTH & $enable) ? MonthAction::class : null, |
|
130 | 1 | ObjectRoute::YEAR_STR => (ObjectRoute::YEAR & $enable) ? YearAction::class : null, |
|
131 | 1 | ], |
|
132 | 6 - $datePrecision |
||
133 | 1 | ); |
|
134 | } |
||
135 | |||
136 | /** |
||
137 | * Prepare and return a route action |
||
138 | * |
||
139 | * @param ServerRequestInterface $request Request |
||
140 | * @param AbstractActionRoute $route Route |
||
141 | * @return ActionInterface|Callable $action Action |
||
142 | */ |
||
143 | 79 | public function getRouteAction(ServerRequestInterface $request, AbstractActionRoute $route) |
|
147 | |||
148 | /** |
||
149 | * Return view resources |
||
150 | * |
||
151 | * @param string|null $name Optional: view resource name |
||
152 | * @return array View resources |
||
153 | */ |
||
154 | 77 | public function getViewResources($name = null) |
|
155 | { |
||
156 | 77 | return ($name === null) ? |
|
157 | 77 | $this->viewResources : |
|
158 | 77 | (array_key_exists($name, $this->viewResources) ? $this->viewResources[$name] : null); |
|
159 | } |
||
160 | |||
161 | /** |
||
162 | * Set the view resources |
||
163 | * |
||
164 | * @param array $viewResources View resources |
||
165 | */ |
||
166 | 1 | public function setViewResources(array $viewResources) |
|
170 | } |
||
171 |