Code Duplication    Length = 19-20 lines in 2 locations

src/allejo/stakx/Compiler.php 2 locations

@@ 439-457 (lines=19) @@
436
     *
437
     * @return string
438
     */
439
    private function buildDynamicPageViewHTML(TemplateInterface &$template, TemplateReadyDocument &$twigItem)
440
    {
441
        $defaultContext = [
442
            'this' => $twigItem->createJail(),
443
        ];
444
445
        $preEvent = new CompileProcessPreRenderPageView(BasePageView::DYNAMIC_TYPE);
446
        $this->eventDispatcher->dispatch(CompileProcessPreRenderPageView::NAME, $preEvent);
447
448
        $context = array_merge($preEvent->getCustomVariables(), $defaultContext);
449
        $output = $template
450
            ->render($context)
451
        ;
452
453
        $postEvent = new CompileProcessPostRenderPageView(BasePageView::DYNAMIC_TYPE, $output);
454
        $this->eventDispatcher->dispatch(CompileProcessPostRenderPageView::NAME, $postEvent);
455
456
        return $postEvent->getCompiledOutput();
457
    }
458
459
    /**
460
     * Get the compiled HTML for a static PageView.
@@ 468-487 (lines=20) @@
465
     *
466
     * @return string
467
     */
468
    private function buildStaticPageViewHTML(StaticPageView &$pageView)
469
    {
470
        $defaultContext = [
471
            'this' => $pageView->createJail(),
472
        ];
473
474
        $preEvent = new CompileProcessPreRenderPageView(BasePageView::STATIC_TYPE);
475
        $this->eventDispatcher->dispatch(CompileProcessPreRenderPageView::NAME, $preEvent);
476
477
        $context = array_merge($preEvent->getCustomVariables(), $defaultContext);
478
        $output = $this
479
            ->createTwigTemplate($pageView)
480
            ->render($context)
481
        ;
482
483
        $postEvent = new CompileProcessPostRenderPageView(BasePageView::STATIC_TYPE, $output);
484
        $this->eventDispatcher->dispatch(CompileProcessPostRenderPageView::NAME, $postEvent);
485
486
        return $postEvent->getCompiledOutput();
487
    }
488
489
    /**
490
     * Create a Twig template that just needs an array to render.