Code Duplication    Length = 19-20 lines in 2 locations

src/allejo/stakx/Compiler.php 2 locations

@@ 476-494 (lines=19) @@
473
     *
474
     * @return string
475
     */
476
    private function renderDynamicPageView(TemplateInterface &$template, TemplateReadyDocument &$twigItem)
477
    {
478
        $defaultContext = [
479
            'this' => $twigItem->createJail(),
480
        ];
481
482
        $preEvent = new CompileProcessPreRenderPageView(BasePageView::DYNAMIC_TYPE);
483
        $this->eventDispatcher->dispatch(CompileProcessPreRenderPageView::NAME, $preEvent);
484
485
        $content = array_merge($preEvent->getCustomVariables(), $defaultContext);
486
        $output = $template
487
            ->render($content)
488
        ;
489
490
        $postEvent = new CompileProcessPostRenderPageView(BasePageView::DYNAMIC_TYPE, $output);
491
        $this->eventDispatcher->dispatch(CompileProcessPostRenderPageView::NAME, $postEvent);
492
493
        return $postEvent->getCompiledOutput();
494
    }
495
496
    /**
497
     * Get the compiled HTML for a static PageView.
@@ 505-524 (lines=20) @@
502
     *
503
     * @return string
504
     */
505
    private function renderStaticPageView(StaticPageView &$pageView)
506
    {
507
        $defaultContext = [
508
            'this' => $pageView->createJail(),
509
        ];
510
511
        $preEvent = new CompileProcessPreRenderPageView(BasePageView::STATIC_TYPE);
512
        $this->eventDispatcher->dispatch(CompileProcessPreRenderPageView::NAME, $preEvent);
513
514
        $context = array_merge($preEvent->getCustomVariables(), $defaultContext);
515
        $output = $this
516
            ->createTwigTemplate($pageView)
517
            ->render($context)
518
        ;
519
520
        $postEvent = new CompileProcessPostRenderPageView(BasePageView::STATIC_TYPE, $output);
521
        $this->eventDispatcher->dispatch(CompileProcessPostRenderPageView::NAME, $postEvent);
522
523
        return $postEvent->getCompiledOutput();
524
    }
525
526
    /**
527
     * Create a Twig template that just needs an array to render.