vendor/kobizo/cms-bundle/src/Controller/ViewHelper/BaseViewHelper.php line 19

Open in your IDE?
  1. <?php
  2. namespace Kobizo\Bundle\CmsBundle\Controller\ViewHelper;
  3. use Kobizo\Bundle\CmsBundle\Controller\ViewHelper\Checker\ViewChecker;
  4. use Kobizo\Component\Configuration\Frontend\TemplateConfig;
  5. abstract class BaseViewHelper
  6. {
  7.     private TemplateConfig $templateConfig;
  8.     private ViewChecker $viewChecker;
  9.     public function __construct(TemplateConfig $templateConfigViewChecker $viewChecker)
  10.     {
  11.         $this->templateConfig $templateConfig;
  12.         $this->viewChecker $viewChecker;
  13.     }
  14.     protected function getViewByTemplate(string $view, ?string $template null): string
  15.     {
  16.         $viewByApp str_replace('@KobizoCms/frontend'$this->templateConfig->getValue(nulltrue), $view);
  17.         $viewBySlug $template str_replace('twig'"$template.twig"$viewByApp) : null;
  18.         if ($viewBySlug && $this->viewChecker->exists($viewBySlug)) {
  19.             return $viewBySlug;
  20.         }
  21.         if ($this->viewChecker->exists($viewByApp)) {
  22.             return $viewByApp;
  23.         }
  24.         return $view;
  25.     }
  26. }