@@ -72,7 +72,8 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | public function tearDown(): void |
| 74 | 74 | { |
| 75 | - if ($this->assetFolder !== null) { |
|
| 75 | + if ($this->assetFolder !== null) |
|
| 76 | + { |
|
| 76 | 77 | fs::remove($this->assetFolder); |
| 77 | 78 | } |
| 78 | 79 | } |
@@ -167,7 +168,8 @@ discard block |
||
| 167 | 168 | { |
| 168 | 169 | $body = $this->buildFrontMatterTemplate($frontMatter, $content); |
| 169 | 170 | |
| 170 | - if (!$filename) { |
|
| 171 | + if (!$filename) |
|
| 172 | + { |
|
| 171 | 173 | $filename = hash('sha256', (string)random_int(0, mt_getrandmax())); |
| 172 | 174 | } |
| 173 | 175 | |
@@ -194,7 +196,8 @@ discard block |
||
| 194 | 196 | { |
| 195 | 197 | $results = []; |
| 196 | 198 | |
| 197 | - foreach ($elements as $element) { |
|
| 199 | + foreach ($elements as $element) |
|
| 200 | + { |
|
| 198 | 201 | $filename = $element['filename'] ?? null; |
| 199 | 202 | $frontMatter = (!isset($element['frontmatter']) || empty($element['frontmatter'])) ? [] : $element['frontmatter']; |
| 200 | 203 | $body = $element['body'] ?? 'Body Text'; |
@@ -405,7 +408,8 @@ discard block |
||
| 405 | 408 | ->value() |
| 406 | 409 | ; |
| 407 | 410 | |
| 408 | - if ($fxnToCall === null) { |
|
| 411 | + if ($fxnToCall === null) |
|
| 412 | + { |
|
| 409 | 413 | throw new BadFunctionCallException(sprintf('No function by the name of "%s" in this class', $method)); |
| 410 | 414 | } |
| 411 | 415 | |
@@ -413,10 +417,14 @@ discard block |
||
| 413 | 417 | $callUserFuncArray = []; |
| 414 | 418 | |
| 415 | 419 | /** @var ReflectionParameter $argument */ |
| 416 | - foreach ($arguments as $argument) { |
|
| 417 | - if (isset($namedParams[$argument->getName()])) { |
|
| 420 | + foreach ($arguments as $argument) |
|
| 421 | + { |
|
| 422 | + if (isset($namedParams[$argument->getName()])) |
|
| 423 | + { |
|
| 418 | 424 | $callUserFuncArray[] = $namedParams[$argument->getName()]; |
| 419 | - } else { |
|
| 425 | + } |
|
| 426 | + else |
|
| 427 | + { |
|
| 420 | 428 | $callUserFuncArray[] = $argument->getDefaultValue(); |
| 421 | 429 | } |
| 422 | 430 | } |
@@ -176,7 +176,8 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | public function compileAll(): void |
| 178 | 178 | { |
| 179 | - foreach ($this->pageViewsFlattened as &$pageView) { |
|
| 179 | + foreach ($this->pageViewsFlattened as &$pageView) |
|
| 180 | + { |
|
| 180 | 181 | $this->compilePageView($pageView); |
| 181 | 182 | } |
| 182 | 183 | } |
@@ -199,8 +200,10 @@ discard block |
||
| 199 | 200 | 'type' => $pageView->getType(), |
| 200 | 201 | ]); |
| 201 | 202 | |
| 202 | - try { |
|
| 203 | - switch ($pageView->getType()) { |
|
| 203 | + try |
|
| 204 | + { |
|
| 205 | + switch ($pageView->getType()) |
|
| 206 | + { |
|
| 204 | 207 | case BasePageView::STATIC_TYPE: |
| 205 | 208 | $this->compileStaticPageView($pageView); |
| 206 | 209 | $this->compileStandardRedirects($pageView); |
@@ -219,7 +222,9 @@ discard block |
||
| 219 | 222 | |
| 220 | 223 | break; |
| 221 | 224 | } |
| 222 | - } catch (TemplateErrorInterface $e) { |
|
| 225 | + } |
|
| 226 | + catch (TemplateErrorInterface $e) |
|
| 227 | + { |
|
| 223 | 228 | throw new FileAwareException( |
| 224 | 229 | $e->getMessage(), |
| 225 | 230 | $e->getCode(), |
@@ -258,8 +263,10 @@ discard block |
||
| 258 | 263 | $contentItems = $pageView->getCollectableItems(); |
| 259 | 264 | $template = $this->createTwigTemplate($pageView); |
| 260 | 265 | |
| 261 | - foreach ($contentItems as &$contentItem) { |
|
| 262 | - if ($contentItem->isDraft() && !Service::hasRunTimeFlag(RuntimeStatus::USING_DRAFTS)) { |
|
| 266 | + foreach ($contentItems as &$contentItem) |
|
| 267 | + { |
|
| 268 | + if ($contentItem->isDraft() && !Service::hasRunTimeFlag(RuntimeStatus::USING_DRAFTS)) |
|
| 269 | + { |
|
| 263 | 270 | $this->logger->debug('{file}: marked as a draft', [ |
| 264 | 271 | 'file' => $contentItem->getRelativeFilePath(), |
| 265 | 272 | ]); |
@@ -289,7 +296,8 @@ discard block |
||
| 289 | 296 | $template = $this->createTwigTemplate($pageView); |
| 290 | 297 | $permalinks = $pageView->getRepeaterPermalinks(); |
| 291 | 298 | |
| 292 | - foreach ($permalinks as $permalink) { |
|
| 299 | + foreach ($permalinks as $permalink) |
|
| 300 | + { |
|
| 293 | 301 | $this->writeToFilesystem( |
| 294 | 302 | $pageView->getTargetFile($permalink->getEvaluated()), |
| 295 | 303 | $this->buildRepeaterPageViewHTML($template, $pageView, $permalink), |
@@ -329,7 +337,8 @@ discard block |
||
| 329 | 337 | { |
| 330 | 338 | $redirects = $pageView->getRedirects(); |
| 331 | 339 | |
| 332 | - foreach ($redirects as $redirect) { |
|
| 340 | + foreach ($redirects as $redirect) |
|
| 341 | + { |
|
| 333 | 342 | $redirectPageView = BasePageView::createRedirect( |
| 334 | 343 | $redirect, |
| 335 | 344 | $pageView->getPermalink(), |
@@ -361,9 +370,11 @@ discard block |
||
| 361 | 370 | $permalinks = $pageView->getRepeaterPermalinks(); |
| 362 | 371 | |
| 363 | 372 | /** @var ExpandedValue[] $repeaterRedirect */ |
| 364 | - foreach ($pageView->getRepeaterRedirects() as $repeaterRedirect) { |
|
| 373 | + foreach ($pageView->getRepeaterRedirects() as $repeaterRedirect) |
|
| 374 | + { |
|
| 365 | 375 | /** @var ExpandedValue $redirect */ |
| 366 | - foreach ($repeaterRedirect as $index => $redirect) { |
|
| 376 | + foreach ($repeaterRedirect as $index => $redirect) |
|
| 377 | + { |
|
| 367 | 378 | $redirectPageView = BasePageView::createRedirect( |
| 368 | 379 | $redirect->getEvaluated(), |
| 369 | 380 | $permalinks[$index]->getEvaluated(), |
@@ -482,7 +493,8 @@ discard block |
||
| 482 | 493 | */ |
| 483 | 494 | private function createTwigTemplate(BasePageView &$pageView): TemplateInterface |
| 484 | 495 | { |
| 485 | - try { |
|
| 496 | + try |
|
| 497 | + { |
|
| 486 | 498 | $template = $this->templateBridge->createTemplate($pageView->getContent()); |
| 487 | 499 | |
| 488 | 500 | $this->templateMapping[$template->getTemplateName()] = $pageView->getRelativeFilePath(); |
@@ -491,7 +503,9 @@ discard block |
||
| 491 | 503 | $this->eventDispatcher->dispatch($event, CompilerTemplateCreation::NAME); |
| 492 | 504 | |
| 493 | 505 | return $template; |
| 494 | - } catch (TemplateErrorInterface $e) { |
|
| 506 | + } |
|
| 507 | + catch (TemplateErrorInterface $e) |
|
| 508 | + { |
|
| 495 | 509 | $e |
| 496 | 510 | ->setTemplateLine($e->getTemplateLine() + $pageView->getLineOffset()) |
| 497 | 511 | ->setContent($pageView->getContent()) |
@@ -19,7 +19,8 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | public function addAssetEngines(/* iterable */ $assetEngines): void |
| 21 | 21 | { |
| 22 | - foreach ($assetEngines as $assetEngine) { |
|
| 22 | + foreach ($assetEngines as $assetEngine) |
|
| 23 | + { |
|
| 23 | 24 | $this->addAssetEngine($assetEngine); |
| 24 | 25 | } |
| 25 | 26 | } |
@@ -30,7 +31,8 @@ discard block |
||
| 30 | 31 | |
| 31 | 32 | $e = $this->engines[] = $assetEngine; |
| 32 | 33 | |
| 33 | - foreach ($extensions as $extension) { |
|
| 34 | + foreach ($extensions as $extension) |
|
| 35 | + { |
|
| 34 | 36 | $this->enginesByExtension[$extension] = $e; |
| 35 | 37 | } |
| 36 | 38 | |
@@ -44,7 +46,8 @@ discard block |
||
| 44 | 46 | |
| 45 | 47 | public function getEngineByExtension($extension) |
| 46 | 48 | { |
| 47 | - if (isset($this->enginesByExtension[$extension])) { |
|
| 49 | + if (isset($this->enginesByExtension[$extension])) |
|
| 50 | + { |
|
| 48 | 51 | return $this->enginesByExtension[$extension]; |
| 49 | 52 | } |
| 50 | 53 | |
@@ -84,7 +84,8 @@ discard block |
||
| 84 | 84 | $this->handleThemeImports($content); |
| 85 | 85 | |
| 86 | 86 | // We don't need to write the source map to a file |
| 87 | - if (!$this->fileSourceMap) { |
|
| 87 | + if (!$this->fileSourceMap) |
|
| 88 | + { |
|
| 88 | 89 | $this->compiler->setSourceMapOptions($sourceMapOptions); |
| 89 | 90 | |
| 90 | 91 | return $this->compiler->compile($content); |
@@ -138,13 +139,16 @@ discard block |
||
| 138 | 139 | |
| 139 | 140 | public static function stringToFormatter($format) |
| 140 | 141 | { |
| 141 | - if ($format === 'nested') { |
|
| 142 | + if ($format === 'nested') |
|
| 143 | + { |
|
| 142 | 144 | return Nested::class; |
| 143 | 145 | } |
| 144 | - if ($format === 'expanded') { |
|
| 146 | + if ($format === 'expanded') |
|
| 147 | + { |
|
| 145 | 148 | return Expanded::class; |
| 146 | 149 | } |
| 147 | - if ($format === 'compact') { |
|
| 150 | + if ($format === 'compact') |
|
| 151 | + { |
|
| 148 | 152 | return Compact::class; |
| 149 | 153 | } |
| 150 | 154 | |
@@ -167,12 +171,17 @@ discard block |
||
| 167 | 171 | { |
| 168 | 172 | $sourceMap = __::get($this->options, 'sourcemap'); |
| 169 | 173 | |
| 170 | - if ($sourceMap === 'inline') { |
|
| 174 | + if ($sourceMap === 'inline') |
|
| 175 | + { |
|
| 171 | 176 | $this->compiler->setSourceMap(Compiler::SOURCE_MAP_INLINE); |
| 172 | - } elseif ($sourceMap === true) { |
|
| 177 | + } |
|
| 178 | + elseif ($sourceMap === true) |
|
| 179 | + { |
|
| 173 | 180 | $this->compiler->setSourceMap(Compiler::SOURCE_MAP_FILE); |
| 174 | 181 | $this->fileSourceMap = true; |
| 175 | - } else { |
|
| 182 | + } |
|
| 183 | + else |
|
| 184 | + { |
|
| 176 | 185 | $this->compiler->setSourceMap(Compiler::SOURCE_MAP_NONE); |
| 177 | 186 | } |
| 178 | 187 | } |
@@ -187,14 +196,16 @@ discard block |
||
| 187 | 196 | |
| 188 | 197 | private function initializeCompiler(): void |
| 189 | 198 | { |
| 190 | - if ($this->compiler) { |
|
| 199 | + if ($this->compiler) |
|
| 200 | + { |
|
| 191 | 201 | return; |
| 192 | 202 | } |
| 193 | 203 | |
| 194 | 204 | $cacheOptions = []; |
| 195 | 205 | |
| 196 | 206 | // If we have a cache directory set, use it. |
| 197 | - if ($this->cacheDirectory) { |
|
| 207 | + if ($this->cacheDirectory) |
|
| 208 | + { |
|
| 198 | 209 | $cacheOptions = [ |
| 199 | 210 | 'cacheDir' => (string)$this->cacheDirectory->getFilesystemPath(), |
| 200 | 211 | 'forceRefresh' => false, |
@@ -210,7 +221,8 @@ discard block |
||
| 210 | 221 | |
| 211 | 222 | private function handleThemeImports(&$content): void |
| 212 | 223 | { |
| 213 | - if ($themeName = $this->configuration->getTheme()) { |
|
| 224 | + if ($themeName = $this->configuration->getTheme()) |
|
| 225 | + { |
|
| 214 | 226 | $themePath = "../_themes/{$themeName}/_sass"; |
| 215 | 227 | $content = preg_replace("/(@import ['\"])(@theme)(.+)/", "$1{$themePath}$3", $content); |
| 216 | 228 | } |
@@ -46,11 +46,13 @@ |
||
| 46 | 46 | */ |
| 47 | 47 | public function registerPageView(BasePageView $pageView): void |
| 48 | 48 | { |
| 49 | - switch ($pageView->getType()) { |
|
| 49 | + switch ($pageView->getType()) |
|
| 50 | + { |
|
| 50 | 51 | case BasePageView::STATIC_TYPE: |
| 51 | 52 | $this->mapping[$pageView->getPermalink()] = $pageView; |
| 52 | 53 | |
| 53 | - foreach ($pageView->getRedirects() as $redirect) { |
|
| 54 | + foreach ($pageView->getRedirects() as $redirect) |
|
| 55 | + { |
|
| 54 | 56 | $this->redirects[$redirect] = $pageView->getPermalink(); |
| 55 | 57 | } |
| 56 | 58 | |
@@ -20,7 +20,8 @@ |
||
| 20 | 20 | $source = fs::getInternalResource('error.html.twig'); |
| 21 | 21 | $template = $compiler->getTemplateBridge()->createTemplate($source); |
| 22 | 22 | |
| 23 | - if ($exception instanceof TemplateErrorInterface) { |
|
| 23 | + if ($exception instanceof TemplateErrorInterface) |
|
| 24 | + { |
|
| 24 | 25 | $message = [ |
| 25 | 26 | sprintf('File: %s:%d', $exception->getRelativeFilePath(), $exception->getTemplateLine()), |
| 26 | 27 | ]; |
@@ -51,29 +51,36 @@ discard block |
||
| 51 | 51 | { |
| 52 | 52 | $routes = Controller::create($routeMapper, $compiler); |
| 53 | 53 | |
| 54 | - return new Server(function (ServerRequestInterface $request) use ($routes, $compiler, $assetManager) { |
|
| 54 | + return new Server(function (ServerRequestInterface $request) use ($routes, $compiler, $assetManager) |
|
| 55 | + { |
|
| 55 | 56 | $httpMethod = $request->getMethod(); |
| 56 | 57 | $urlPath = Controller::normalizeUrl($request->getUri()->getPath()); |
| 57 | 58 | |
| 58 | 59 | // We're a static website, we should never support anything other than GET requests |
| 59 | - if ($httpMethod !== 'GET') { |
|
| 60 | + if ($httpMethod !== 'GET') |
|
| 61 | + { |
|
| 60 | 62 | return new Response(406, ['Content-Type' => 'text/plain'], 'Method not allowed'); |
| 61 | 63 | } |
| 62 | 64 | |
| 63 | 65 | $context = new RequestContext($urlPath); |
| 64 | 66 | $matcher = new UrlMatcher($routes, $context); |
| 65 | 67 | |
| 66 | - try { |
|
| 68 | + try |
|
| 69 | + { |
|
| 67 | 70 | $parameters = $matcher->match($urlPath); |
| 68 | 71 | |
| 69 | - if (isset($parameters['_controller'])) { |
|
| 72 | + if (isset($parameters['_controller'])) |
|
| 73 | + { |
|
| 70 | 74 | $controller = $parameters['_controller']; |
| 71 | 75 | |
| 72 | 76 | return $controller($request, ...array_values($parameters)); |
| 73 | 77 | } |
| 74 | - } catch (ResourceNotFoundException $e) { |
|
| 78 | + } |
|
| 79 | + catch (ResourceNotFoundException $e) |
|
| 80 | + { |
|
| 75 | 81 | // If we have a "manual" asset, let's serve from it |
| 76 | - if (($file = $assetManager->getExplicitAsset(self::normalizePath($urlPath))) !== null) { |
|
| 82 | + if (($file = $assetManager->getExplicitAsset(self::normalizePath($urlPath))) !== null) |
|
| 83 | + { |
|
| 77 | 84 | return self::makeResponse($file); |
| 78 | 85 | } |
| 79 | 86 | |
@@ -82,10 +89,13 @@ discard block |
||
| 82 | 89 | // reason, we manually look through the filesystem and load from there. |
| 83 | 90 | // |
| 84 | 91 | // @TODO this should be fixed to make the AssetManager the authority on assets. |
| 85 | - if (($asset = self::searchAsset($urlPath)) !== null) { |
|
| 92 | + if (($asset = self::searchAsset($urlPath)) !== null) |
|
| 93 | + { |
|
| 86 | 94 | return $asset; |
| 87 | 95 | } |
| 88 | - } catch (Exception $e) { |
|
| 96 | + } |
|
| 97 | + catch (Exception $e) |
|
| 98 | + { |
|
| 89 | 99 | $response = ExceptionRenderer::render($e, $compiler); |
| 90 | 100 | |
| 91 | 101 | return new Response(500, ['Content-Type' => 'text/html'], $response); |
@@ -103,12 +113,16 @@ discard block |
||
| 103 | 113 | */ |
| 104 | 114 | private static function searchAsset($url, $continueNesting = true): ?Response |
| 105 | 115 | { |
| 106 | - try { |
|
| 116 | + try |
|
| 117 | + { |
|
| 107 | 118 | $file = new File(self::normalizePath($url)); |
| 108 | 119 | |
| 109 | 120 | return self::makeResponse($file); |
| 110 | - } catch (FileNotFoundException) { |
|
| 111 | - if (!$continueNesting) { |
|
| 121 | + } |
|
| 122 | + catch (FileNotFoundException) |
|
| 123 | + { |
|
| 124 | + if (!$continueNesting) |
|
| 125 | + { |
|
| 112 | 126 | // This will evaluate to true if we've searched inside the themes folder and it still doesn't exist |
| 113 | 127 | return null; |
| 114 | 128 | } |
@@ -51,7 +51,8 @@ discard block |
||
| 51 | 51 | * @var string $from |
| 52 | 52 | * @var string $to |
| 53 | 53 | */ |
| 54 | - foreach ($routeMapper->getRedirectMapping() as $from => $to) { |
|
| 54 | + foreach ($routeMapper->getRedirectMapping() as $from => $to) |
|
| 55 | + { |
|
| 55 | 56 | $routeName = preg_replace('/[\/\.]/', '_', $from); |
| 56 | 57 | $routeName = 'redirect_' . $routeName; |
| 57 | 58 | |
@@ -64,7 +65,8 @@ discard block |
||
| 64 | 65 | * @var string $routeUrl |
| 65 | 66 | * @var BasePageView $pageView |
| 66 | 67 | */ |
| 67 | - foreach ($routeMapper->getRouteMapping() as $routeUrl => $pageView) { |
|
| 68 | + foreach ($routeMapper->getRouteMapping() as $routeUrl => $pageView) |
|
| 69 | + { |
|
| 68 | 70 | $routeName = $pageView->getRelativeFilePath(); |
| 69 | 71 | $routeName = preg_replace('/[\/\.]/', '_', $routeName); |
| 70 | 72 | |
@@ -75,7 +77,8 @@ discard block |
||
| 75 | 77 | // Allow the last route parameter to have `/` in the permalink that's not part of the route itself |
| 76 | 78 | // see https://github.com/stakx-io/stakx/issues/98 |
| 77 | 79 | $requirements = []; |
| 78 | - if (count($results) >= 2) { |
|
| 80 | + if (count($results) >= 2) |
|
| 81 | + { |
|
| 79 | 82 | $requirements[$results[1]] = '.*'; |
| 80 | 83 | } |
| 81 | 84 | |
@@ -109,12 +112,14 @@ discard block |
||
| 109 | 112 | */ |
| 110 | 113 | private function staticPageViewAction(StaticPageView $pageView, Compiler $compiler): Closure |
| 111 | 114 | { |
| 112 | - return function () use ($pageView, $compiler) { |
|
| 115 | + return function () use ($pageView, $compiler) |
|
| 116 | + { |
|
| 113 | 117 | Service::setOption('currentTemplate', $pageView->getAbsoluteFilePath()); |
| 114 | 118 | |
| 115 | 119 | $compiler->getTemplateBridge()->clearTemplateCache(); |
| 116 | 120 | |
| 117 | - if ($this->hasBeenTouched($pageView)) { |
|
| 121 | + if ($this->hasBeenTouched($pageView)) |
|
| 122 | + { |
|
| 118 | 123 | $pageView->readContent(); |
| 119 | 124 | } |
| 120 | 125 | |
@@ -133,22 +138,26 @@ discard block |
||
| 133 | 138 | */ |
| 134 | 139 | private function dynamicPageViewAction(DynamicPageView $pageView, Compiler $compiler): Closure |
| 135 | 140 | { |
| 136 | - return function (ServerRequestInterface $request) use ($pageView, $compiler) { |
|
| 141 | + return function (ServerRequestInterface $request) use ($pageView, $compiler) |
|
| 142 | + { |
|
| 137 | 143 | Service::setOption('currentTemplate', $pageView->getAbsoluteFilePath()); |
| 138 | 144 | |
| 139 | 145 | $compiler->getTemplateBridge()->clearTemplateCache(); |
| 140 | 146 | |
| 141 | 147 | $contentItem = self::getContentItem($pageView, $request->getUri()->getPath()); |
| 142 | 148 | |
| 143 | - if ($contentItem === null) { |
|
| 149 | + if ($contentItem === null) |
|
| 150 | + { |
|
| 144 | 151 | return WebServer::return404(); |
| 145 | 152 | } |
| 146 | 153 | |
| 147 | - if ($this->hasBeenTouched($pageView)) { |
|
| 154 | + if ($this->hasBeenTouched($pageView)) |
|
| 155 | + { |
|
| 148 | 156 | $pageView->readContent(); |
| 149 | 157 | } |
| 150 | 158 | |
| 151 | - if ($this->hasBeenTouched($contentItem)) { |
|
| 159 | + if ($this->hasBeenTouched($contentItem)) |
|
| 160 | + { |
|
| 152 | 161 | $contentItem->readContent(); |
| 153 | 162 | } |
| 154 | 163 | |
@@ -161,18 +170,21 @@ discard block |
||
| 161 | 170 | */ |
| 162 | 171 | private function repeaterPageViewAction(RepeaterPageView $pageView, Compiler $compiler): Closure |
| 163 | 172 | { |
| 164 | - return function (ServerRequestInterface $request) use ($pageView, $compiler) { |
|
| 173 | + return function (ServerRequestInterface $request) use ($pageView, $compiler) |
|
| 174 | + { |
|
| 165 | 175 | Service::setOption('currentTemplate', $pageView->getAbsoluteFilePath()); |
| 166 | 176 | |
| 167 | 177 | $compiler->getTemplateBridge()->clearTemplateCache(); |
| 168 | 178 | |
| 169 | 179 | $expandedValue = self::getExpandedValue($pageView, $request->getUri()->getPath()); |
| 170 | 180 | |
| 171 | - if ($expandedValue === null) { |
|
| 181 | + if ($expandedValue === null) |
|
| 182 | + { |
|
| 172 | 183 | return WebServer::return404(); |
| 173 | 184 | } |
| 174 | 185 | |
| 175 | - if ($this->hasBeenTouched($pageView)) { |
|
| 186 | + if ($this->hasBeenTouched($pageView)) |
|
| 187 | + { |
|
| 176 | 188 | $pageView->readContent(); |
| 177 | 189 | } |
| 178 | 190 | |
@@ -189,7 +201,8 @@ discard block |
||
| 189 | 201 | BasePageView::STATIC_TYPE => $this->staticPageViewAction($pageView, $compiler), |
| 190 | 202 | BasePageView::DYNAMIC_TYPE => $this->dynamicPageViewAction($pageView, $compiler), |
| 191 | 203 | BasePageView::REPEATER_TYPE => $this->repeaterPageViewAction($pageView, $compiler), |
| 192 | - default => function () { |
|
| 204 | + default => function () |
|
| 205 | + { |
|
| 193 | 206 | $errMsg = 'This URL type has not yet been implemented.'; |
| 194 | 207 | |
| 195 | 208 | return new Response(501, ['Content-Type' => 'text/plain'], $errMsg); |
@@ -218,7 +231,8 @@ discard block |
||
| 218 | 231 | { |
| 219 | 232 | $rPath = $document->getRelativeFilePath(); |
| 220 | 233 | |
| 221 | - if (!isset($this->lastModified[$rPath])) { |
|
| 234 | + if (!isset($this->lastModified[$rPath])) |
|
| 235 | + { |
|
| 222 | 236 | $this->lastModified[$rPath] = $document->getLastModified(); |
| 223 | 237 | |
| 224 | 238 | return true; |
@@ -236,8 +250,10 @@ discard block |
||
| 236 | 250 | { |
| 237 | 251 | $permalink = self::normalizeUrl($permalink); |
| 238 | 252 | |
| 239 | - foreach ($pageView->getCollectableItems() as $collectableItem) { |
|
| 240 | - if ($collectableItem['permalink'] === $permalink) { |
|
| 253 | + foreach ($pageView->getCollectableItems() as $collectableItem) |
|
| 254 | + { |
|
| 255 | + if ($collectableItem['permalink'] === $permalink) |
|
| 256 | + { |
|
| 241 | 257 | return $collectableItem; |
| 242 | 258 | } |
| 243 | 259 | } |
@@ -253,8 +269,10 @@ discard block |
||
| 253 | 269 | $url = self::normalizeUrl($permalink); |
| 254 | 270 | $repeaterPermalinks = $pageView->getRepeaterPermalinks(); |
| 255 | 271 | |
| 256 | - foreach ($repeaterPermalinks as $expandedValue) { |
|
| 257 | - if ($expandedValue->getEvaluated() === $url) { |
|
| 272 | + foreach ($repeaterPermalinks as $expandedValue) |
|
| 273 | + { |
|
| 274 | + if ($expandedValue->getEvaluated() === $url) |
|
| 275 | + { |
|
| 258 | 276 | return $expandedValue; |
| 259 | 277 | } |
| 260 | 278 | } |
@@ -43,7 +43,8 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function build(): bool |
| 45 | 45 | { |
| 46 | - if (empty($this->getConfiguration()->getPageViewFolders())) { |
|
| 46 | + if (empty($this->getConfiguration()->getPageViewFolders())) |
|
| 47 | + { |
|
| 47 | 48 | $this->logger->error('No PageViews were configured for this site. Check the `pageviews` key in your _config.yml.'); |
| 48 | 49 | |
| 49 | 50 | return false; |
@@ -63,10 +64,14 @@ discard block |
||
| 63 | 64 | $this->compiler->setThemeName($theme); |
| 64 | 65 | $this->compiler->compileAll(); |
| 65 | 66 | |
| 66 | - if (Service::hasRunTimeFlag(RuntimeStatus::IN_PROFILE_MODE)) { |
|
| 67 | - if (!$this->templateBridge->hasProfiler()) { |
|
| 67 | + if (Service::hasRunTimeFlag(RuntimeStatus::IN_PROFILE_MODE)) |
|
| 68 | + { |
|
| 69 | + if (!$this->templateBridge->hasProfiler()) |
|
| 70 | + { |
|
| 68 | 71 | $this->logger->writeln('This template engine currently does not support a profiler.'); |
| 69 | - } else { |
|
| 72 | + } |
|
| 73 | + else |
|
| 74 | + { |
|
| 70 | 75 | $profilerText = $this->templateBridge->getProfilerOutput($this->compiler); |
| 71 | 76 | $this->logger->writeln($profilerText); |
| 72 | 77 | } |
@@ -82,7 +87,8 @@ discard block |
||
| 82 | 87 | // |
| 83 | 88 | // Theme Management |
| 84 | 89 | // |
| 85 | - if ($theme !== null) { |
|
| 90 | + if ($theme !== null) |
|
| 91 | + { |
|
| 86 | 92 | $this->logger->notice("Looking for '{$theme}' theme..."); |
| 87 | 93 | |
| 88 | 94 | $tm = new ThemeManager($theme, $this->eventDispatcher, $this->logger); |
@@ -113,11 +119,13 @@ discard block |
||
| 113 | 119 | { |
| 114 | 120 | $targetDir = fs::absolutePath($this->getConfiguration()->getTargetFolder()); |
| 115 | 121 | |
| 116 | - if (!Service::hasRunTimeFlag(RuntimeStatus::BOOT_WITHOUT_CLEAN)) { |
|
| 122 | + if (!Service::hasRunTimeFlag(RuntimeStatus::BOOT_WITHOUT_CLEAN)) |
|
| 123 | + { |
|
| 117 | 124 | fs::remove($targetDir); |
| 118 | 125 | } |
| 119 | 126 | |
| 120 | - if (!Service::hasRunTimeFlag(RuntimeStatus::USING_CACHE)) { |
|
| 127 | + if (!Service::hasRunTimeFlag(RuntimeStatus::USING_CACHE)) |
|
| 128 | + { |
|
| 121 | 129 | fs::remove(fs::absolutePath(Configuration::CACHE_FOLDER, 'twig')); |
| 122 | 130 | fs::mkdir(fs::absolutePath(fs::appendPath(Configuration::CACHE_FOLDER, 'twig'))); |
| 123 | 131 | } |
@@ -132,20 +140,24 @@ discard block |
||
| 132 | 140 | { |
| 133 | 141 | $enabled = $this->getConfiguration()->isHighlighterEnabled(); |
| 134 | 142 | |
| 135 | - if (!$enabled) { |
|
| 143 | + if (!$enabled) |
|
| 144 | + { |
|
| 136 | 145 | return; |
| 137 | 146 | } |
| 138 | 147 | |
| 139 | 148 | Service::setRuntimeFlag(RuntimeStatus::USING_HIGHLIGHTER); |
| 140 | 149 | |
| 141 | - if ($this->getConfiguration()->isHighlighterUsingLineNumbers()) { |
|
| 150 | + if ($this->getConfiguration()->isHighlighterUsingLineNumbers()) |
|
| 151 | + { |
|
| 142 | 152 | Service::setRuntimeFlag(RuntimeStatus::USING_LINE_NUMBERS); |
| 143 | 153 | } |
| 144 | 154 | |
| 145 | - foreach ($this->getConfiguration()->getHighlighterCustomLanguages() as $lang => $path) { |
|
| 155 | + foreach ($this->getConfiguration()->getHighlighterCustomLanguages() as $lang => $path) |
|
| 156 | + { |
|
| 146 | 157 | $fullPath = fs::absolutePath($path); |
| 147 | 158 | |
| 148 | - if (!fs::exists($fullPath)) { |
|
| 159 | + if (!fs::exists($fullPath)) |
|
| 160 | + { |
|
| 149 | 161 | $this->logger->warning('The following language definition could not be found: {lang}', [ |
| 150 | 162 | 'lang' => $path, |
| 151 | 163 | ]); |