@@ -13,11 +13,18 @@ discard block |
||
| 13 | 13 | protected static $runTimeStatus; |
| 14 | 14 | protected static $options; |
| 15 | 15 | |
| 16 | + /** |
|
| 17 | + * @param string $key |
|
| 18 | + * @param string $value |
|
| 19 | + */ |
|
| 16 | 20 | public static function setOption($key, $value) |
| 17 | 21 | { |
| 18 | 22 | self::$options[$key] = $value; |
| 19 | 23 | } |
| 20 | 24 | |
| 25 | + /** |
|
| 26 | + * @param string $key |
|
| 27 | + */ |
|
| 21 | 28 | public static function getOption($key) |
| 22 | 29 | { |
| 23 | 30 | return isset(self::$options[$key]) ? self::$options[$key] : null; |
@@ -48,6 +55,9 @@ discard block |
||
| 48 | 55 | return self::$workingDirectory; |
| 49 | 56 | } |
| 50 | 57 | |
| 58 | + /** |
|
| 59 | + * @param \string|null $directory |
|
| 60 | + */ |
|
| 51 | 61 | public static function setWorkingDirectory($directory) |
| 52 | 62 | { |
| 53 | 63 | self::$workingDirectory = $directory; |
@@ -152,6 +152,9 @@ discard block |
||
| 152 | 152 | }); |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | + /** |
|
| 156 | + * @param string $url |
|
| 157 | + */ |
|
| 155 | 158 | public static function normalizeUrl($url) |
| 156 | 159 | { |
| 157 | 160 | return str_replace(self::$baseUrl, '/', $url); |
@@ -163,7 +166,7 @@ discard block |
||
| 163 | 166 | * @param DynamicPageView $pageView |
| 164 | 167 | * @param $permalink |
| 165 | 168 | * |
| 166 | - * @return CollectableItem|ReadableDocument|TemplateReadyDocument|null |
|
| 169 | + * @return CollectableItem|null |
|
| 167 | 170 | */ |
| 168 | 171 | private static function getContentItem(DynamicPageView $pageView, $permalink) |
| 169 | 172 | { |
@@ -43,7 +43,8 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | private function staticPageViewController(StaticPageView $pageView, Compiler $compiler) |
| 45 | 45 | { |
| 46 | - return function () use ($pageView, $compiler) { |
|
| 46 | + return function () use ($pageView, $compiler) |
|
| 47 | + { |
|
| 47 | 48 | Service::setOption('currentTemplate', $pageView->getAbsoluteFilePath()); |
| 48 | 49 | |
| 49 | 50 | if ($this->hasBeenTouched($pageView)) |
@@ -71,7 +72,8 @@ discard block |
||
| 71 | 72 | */ |
| 72 | 73 | private function dynamicPageViewController(DynamicPageView $pageView, Compiler $compiler) |
| 73 | 74 | { |
| 74 | - return function (ServerRequestInterface $request) use ($pageView, $compiler) { |
|
| 75 | + return function (ServerRequestInterface $request) use ($pageView, $compiler) |
|
| 76 | + { |
|
| 75 | 77 | Service::setOption('currentTemplate', $pageView->getAbsoluteFilePath()); |
| 76 | 78 | |
| 77 | 79 | $contentItem = self::getContentItem($pageView, self::normalizeUrl($request->getUri()->getPath())); |
@@ -104,7 +106,8 @@ discard block |
||
| 104 | 106 | */ |
| 105 | 107 | private function repeaterPageViewController(RepeaterPageView $pageView, Compiler $compiler) |
| 106 | 108 | { |
| 107 | - return function (ServerRequestInterface $request) use ($pageView, $compiler) { |
|
| 109 | + return function (ServerRequestInterface $request) use ($pageView, $compiler) |
|
| 110 | + { |
|
| 108 | 111 | $permalinks = $pageView->getRepeaterPermalinks(); |
| 109 | 112 | $url = self::normalizeUrl($request->getUri()->getPath()); |
| 110 | 113 | |
@@ -144,7 +147,8 @@ discard block |
||
| 144 | 147 | return $this->repeaterPageViewController($pageView, $compiler); |
| 145 | 148 | |
| 146 | 149 | default: |
| 147 | - return function () { |
|
| 150 | + return function () |
|
| 151 | + { |
|
| 148 | 152 | $errMsg = 'This URL type has not yet been implemented.'; |
| 149 | 153 | |
| 150 | 154 | return new Response(501, ['Content-Type' => 'text/plain'], $errMsg); |
@@ -185,7 +189,8 @@ discard block |
||
| 185 | 189 | { |
| 186 | 190 | self::$baseUrl = $router->getBaseUrl(); |
| 187 | 191 | |
| 188 | - return \FastRoute\simpleDispatcher(function (RouteCollector $r) use ($router, $compiler) { |
|
| 192 | + return \FastRoute\simpleDispatcher(function (RouteCollector $r) use ($router, $compiler) |
|
| 193 | + { |
|
| 189 | 194 | $dispatcher = new RouteDispatcher(); |
| 190 | 195 | |
| 191 | 196 | foreach ($router->getRouteMapping() as $route => $pageView) |
@@ -43,7 +43,8 @@ |
||
| 43 | 43 | { |
| 44 | 44 | $dispatcher = RouteDispatcher::create($router, $compiler); |
| 45 | 45 | |
| 46 | - return new Server(function (ServerRequestInterface $request) use ($router, $dispatcher) { |
|
| 46 | + return new Server(function (ServerRequestInterface $request) use ($router, $dispatcher) |
|
| 47 | + { |
|
| 47 | 48 | $httpMethod = $request->getMethod(); |
| 48 | 49 | $urlPath = RouteDispatcher::normalizeUrl($request->getUri()->getPath()); |
| 49 | 50 | |
@@ -103,6 +103,9 @@ |
||
| 103 | 103 | 'json' => 'application/json', |
| 104 | 104 | ]; |
| 105 | 105 | |
| 106 | + /** |
|
| 107 | + * @return \allejo\stakx\Document\StaticPageView |
|
| 108 | + */ |
|
| 106 | 109 | public static function getMimeType($extension) |
| 107 | 110 | { |
| 108 | 111 | return isset(self::$mimes[$extension]) ? self::$mimes[$extension] : null; |