@@ -25,7 +25,8 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | public function addAssetEngines(iterable $assetEngines): void |
| 27 | 27 | { |
| 28 | - foreach ($assetEngines as $assetEngine) { |
|
| 28 | + foreach ($assetEngines as $assetEngine) |
|
| 29 | + { |
|
| 29 | 30 | $this->addAssetEngine($assetEngine); |
| 30 | 31 | } |
| 31 | 32 | } |
@@ -36,7 +37,8 @@ discard block |
||
| 36 | 37 | |
| 37 | 38 | $e = $this->engines[] = $assetEngine; |
| 38 | 39 | |
| 39 | - foreach ($extensions as $extension) { |
|
| 40 | + foreach ($extensions as $extension) |
|
| 41 | + { |
|
| 40 | 42 | $this->enginesByExtension[$extension] = $e; |
| 41 | 43 | } |
| 42 | 44 | |
@@ -56,7 +58,8 @@ discard block |
||
| 56 | 58 | */ |
| 57 | 59 | public function getEngineByExtension(string $extension): AssetEngineInterface |
| 58 | 60 | { |
| 59 | - if (isset($this->enginesByExtension[$extension])) { |
|
| 61 | + if (isset($this->enginesByExtension[$extension])) |
|
| 62 | + { |
|
| 60 | 63 | return $this->enginesByExtension[$extension]; |
| 61 | 64 | } |
| 62 | 65 | |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | class Compiler |
| 45 | 45 | { |
| 46 | - private string|false $redirectTemplate; |
|
| 46 | + private string | false $redirectTemplate; |
|
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | 49 | * All the PageViews handled by this Compiler instance indexed by their file paths relative to the site root. |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | * |
| 291 | 291 | * @throws TemplateErrorInterface |
| 292 | 292 | */ |
| 293 | - private function compileRepeaterPageView(RepeaterPageView &$pageView): void |
|
| 293 | + private function compileRepeaterPageView(RepeaterPageView & $pageView): void |
|
| 294 | 294 | { |
| 295 | 295 | $template = $this->createTwigTemplate($pageView); |
| 296 | 296 | $permalinks = $pageView->getRepeaterPermalinks(); |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | * |
| 332 | 332 | * @since 0.1.1 |
| 333 | 333 | */ |
| 334 | - private function compileStandardRedirects(PermalinkDocument &$pageView): void |
|
| 334 | + private function compileStandardRedirects(PermalinkDocument & $pageView): void |
|
| 335 | 335 | { |
| 336 | 336 | $redirects = $pageView->getRedirects(); |
| 337 | 337 | |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | * |
| 363 | 363 | * @since 0.1.1 |
| 364 | 364 | */ |
| 365 | - private function compileExpandedRedirects(RepeaterPageView &$pageView): void |
|
| 365 | + private function compileExpandedRedirects(RepeaterPageView & $pageView): void |
|
| 366 | 366 | { |
| 367 | 367 | $permalinks = $pageView->getRepeaterPermalinks(); |
| 368 | 368 | |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | * |
| 402 | 402 | * @since 0.1.1 |
| 403 | 403 | */ |
| 404 | - private function buildRepeaterPageViewHTML(TemplateInterface &$template, RepeaterPageView &$pageView, ExpandedValue &$expandedValue): string |
|
| 404 | + private function buildRepeaterPageViewHTML(TemplateInterface & $template, RepeaterPageView & $pageView, ExpandedValue & $expandedValue): string |
|
| 405 | 405 | { |
| 406 | 406 | $defaultContext = [ |
| 407 | 407 | 'this' => $pageView->createJail(), |
@@ -431,7 +431,7 @@ discard block |
||
| 431 | 431 | * |
| 432 | 432 | * @since 0.1.1 |
| 433 | 433 | */ |
| 434 | - private function buildDynamicPageViewHTML(TemplateInterface &$template, CollectableItem|TemplateReadyDocument &$twigItem): string |
|
| 434 | + private function buildDynamicPageViewHTML(TemplateInterface & $template, CollectableItem | TemplateReadyDocument & $twigItem): string |
|
| 435 | 435 | { |
| 436 | 436 | $defaultContext = [ |
| 437 | 437 | 'this' => $twigItem->createJail(), |
@@ -458,7 +458,7 @@ discard block |
||
| 458 | 458 | * |
| 459 | 459 | * @throws TemplateErrorInterface |
| 460 | 460 | */ |
| 461 | - private function buildStaticPageViewHTML(StaticPageView &$pageView): string |
|
| 461 | + private function buildStaticPageViewHTML(StaticPageView & $pageView): string |
|
| 462 | 462 | { |
| 463 | 463 | $defaultContext = [ |
| 464 | 464 | 'this' => $pageView->createJail(), |
@@ -486,7 +486,7 @@ discard block |
||
| 486 | 486 | * |
| 487 | 487 | * @throws TemplateErrorInterface |
| 488 | 488 | */ |
| 489 | - private function createTwigTemplate(BasePageView &$pageView): TemplateInterface |
|
| 489 | + private function createTwigTemplate(BasePageView & $pageView): TemplateInterface |
|
| 490 | 490 | { |
| 491 | 491 | try { |
| 492 | 492 | $template = $this->templateBridge->createTemplate($pageView->getContent()); |
@@ -177,7 +177,8 @@ discard block |
||
| 177 | 177 | */ |
| 178 | 178 | public function compileAll(): void |
| 179 | 179 | { |
| 180 | - foreach ($this->pageViewsFlattened as $pageView) { |
|
| 180 | + foreach ($this->pageViewsFlattened as $pageView) |
|
| 181 | + { |
|
| 181 | 182 | $this->compilePageView($pageView); |
| 182 | 183 | } |
| 183 | 184 | } |
@@ -202,8 +203,10 @@ discard block |
||
| 202 | 203 | 'type' => $pageView->getType(), |
| 203 | 204 | ]); |
| 204 | 205 | |
| 205 | - try { |
|
| 206 | - switch ($pageView->getType()) { |
|
| 206 | + try |
|
| 207 | + { |
|
| 208 | + switch ($pageView->getType()) |
|
| 209 | + { |
|
| 207 | 210 | case BasePageView::STATIC_TYPE: |
| 208 | 211 | /** @var StaticPageView $pageView */ |
| 209 | 212 | $this->compileStaticPageView($pageView); |
@@ -225,7 +228,9 @@ discard block |
||
| 225 | 228 | |
| 226 | 229 | break; |
| 227 | 230 | } |
| 228 | - } catch (TemplateErrorInterface $e) { |
|
| 231 | + } |
|
| 232 | + catch (TemplateErrorInterface $e) |
|
| 233 | + { |
|
| 229 | 234 | throw new FileAwareException( |
| 230 | 235 | $e->getMessage(), |
| 231 | 236 | $e->getCode(), |
@@ -264,8 +269,10 @@ discard block |
||
| 264 | 269 | $contentItems = $pageView->getCollectableItems(); |
| 265 | 270 | $template = $this->createTwigTemplate($pageView); |
| 266 | 271 | |
| 267 | - foreach ($contentItems as &$contentItem) { |
|
| 268 | - if ($contentItem->isDraft() && !Service::hasRunTimeFlag(RuntimeStatus::USING_DRAFTS)) { |
|
| 272 | + foreach ($contentItems as &$contentItem) |
|
| 273 | + { |
|
| 274 | + if ($contentItem->isDraft() && !Service::hasRunTimeFlag(RuntimeStatus::USING_DRAFTS)) |
|
| 275 | + { |
|
| 269 | 276 | $this->logger->debug('{file}: marked as a draft', [ |
| 270 | 277 | 'file' => $contentItem->getRelativeFilePath(), |
| 271 | 278 | ]); |
@@ -295,7 +302,8 @@ discard block |
||
| 295 | 302 | $template = $this->createTwigTemplate($pageView); |
| 296 | 303 | $permalinks = $pageView->getRepeaterPermalinks(); |
| 297 | 304 | |
| 298 | - foreach ($permalinks as $permalink) { |
|
| 305 | + foreach ($permalinks as $permalink) |
|
| 306 | + { |
|
| 299 | 307 | $this->writeToFilesystem( |
| 300 | 308 | $pageView->getTargetFile($permalink->getEvaluated()), |
| 301 | 309 | $this->buildRepeaterPageViewHTML($template, $pageView, $permalink), |
@@ -335,7 +343,8 @@ discard block |
||
| 335 | 343 | { |
| 336 | 344 | $redirects = $pageView->getRedirects(); |
| 337 | 345 | |
| 338 | - foreach ($redirects as $redirect) { |
|
| 346 | + foreach ($redirects as $redirect) |
|
| 347 | + { |
|
| 339 | 348 | $redirectPageView = BasePageView::createRedirect( |
| 340 | 349 | $redirect, |
| 341 | 350 | $pageView->getPermalink(), |
@@ -367,9 +376,11 @@ discard block |
||
| 367 | 376 | $permalinks = $pageView->getRepeaterPermalinks(); |
| 368 | 377 | |
| 369 | 378 | /** @var ExpandedValue[] $repeaterRedirect */ |
| 370 | - foreach ($pageView->getRepeaterRedirects() as $repeaterRedirect) { |
|
| 379 | + foreach ($pageView->getRepeaterRedirects() as $repeaterRedirect) |
|
| 380 | + { |
|
| 371 | 381 | /** @var ExpandedValue $redirect */ |
| 372 | - foreach ($repeaterRedirect as $index => $redirect) { |
|
| 382 | + foreach ($repeaterRedirect as $index => $redirect) |
|
| 383 | + { |
|
| 373 | 384 | $redirectPageView = BasePageView::createRedirect( |
| 374 | 385 | $redirect->getEvaluated(), |
| 375 | 386 | $permalinks[$index]->getEvaluated(), |
@@ -488,7 +499,8 @@ discard block |
||
| 488 | 499 | */ |
| 489 | 500 | private function createTwigTemplate(BasePageView &$pageView): TemplateInterface |
| 490 | 501 | { |
| 491 | - try { |
|
| 502 | + try |
|
| 503 | + { |
|
| 492 | 504 | $template = $this->templateBridge->createTemplate($pageView->getContent()); |
| 493 | 505 | |
| 494 | 506 | $this->templateMapping[$template->getTemplateName()] = $pageView->getRelativeFilePath(); |
@@ -497,7 +509,9 @@ discard block |
||
| 497 | 509 | $this->eventDispatcher->dispatch($event, CompilerTemplateCreation::NAME); |
| 498 | 510 | |
| 499 | 511 | return $template; |
| 500 | - } catch (TemplateErrorInterface $e) { |
|
| 512 | + } |
|
| 513 | + catch (TemplateErrorInterface $e) |
|
| 514 | + { |
|
| 501 | 515 | $e |
| 502 | 516 | ->setTemplateLine($e->getTemplateLine() + $pageView->getLineOffset()) |
| 503 | 517 | ->setContent($pageView->getContent()) |