Create the template loader.

@return \WyriHaximus\TwigView\Lib\Twig\Loader
185324
protected function getLoader(): Loader
    {
        $event = LoaderEvent::create(new Loader());
        $this->getEventManager()->dispatch($event);

        return $event->getResultLoader();
    }
1105992
public function getCode()
    {
        $locator = new TemplateLocator(new FileLocator($this->getTemplateDirs()));
        $templateNameParser = new TemplateNameParser();
        $loader = new FilesystemLoader($locator, $templateNameParser);
        $twig = new \Twig_Environment(
            $loader,
            array(
                'autoescape' => false,
                'strict_variables' => true,
                'debug' => true,
                'cache' => $this->getGenerator()->getTempDir(),
            )
        );

        $this->addTwigExtensions($twig, $loader);
        $this->addTwigFilters($twig);
        $template = $twig->loadTemplate($this->getTemplateName());

        $variables = $this->getVariables();
        $variables['builder'] = $this;

        return $template->render($variables);
    }
676830
protected function createModel()
    {
        $model = $this->loader->getTracker()->getTrackModel();
        $model->applyFormatting(true, true);

        return $model;
    }
1099141
public static function make()
    {
        $resolver = new TemplateResolver();

        $services = Provider::getServices();
        $config   = $services->get('Config');

        if (isset($config['error']['html']['templates'])) {
            $templates = (array) $config['error']['html']['templates'];
            foreach ($templates as $template => $path) {
                $resolver->setTemplate($template, $path);
            }
        }

        return $resolver;
    }
980295
public function compile()
    {
        $templateFilePrefix = $this->hasLocalizedVersion() ?
            $this->generateLocalizedViewPath() :
            $this->generateDefaultViewPath();

        $content = self::parseFile(
            $templateFilePrefix . $this->getConfig('file_extention'),
            $this->contextualVariables,
            (bool)$this->getConfig('allow_debug')
        );

        if (is_null($this->getConfig("layout"))) {
            return $content;
        }

        $layout = self::parseFile(
            $this->generateDefaultLayoutPath() . $this->getConfig('file_extention'),
            $this->contextualVariables,
            (bool)$this->getConfig('allow_debug')
        );

        return str_replace(self::TPL_YIELD, $content, $layout);
    }
752916
protected function createContainerBuilder()
    {
        $builder = new ContainerBuilder();
        $this->kernel->boot();
        foreach ($this->kernel->getBundles() as $bundle) {
            // Register all extensions, otherwise there might be config parts that cannot be processed.
            $extension = $bundle->getContainerExtension();
            if ($extension !== null) {
                $builder->registerExtension($extension);
            }
        }
        // Load the application configuration, which might affect the loaded services.
        /* @var $locator FileLocatorInterface */
        $locator = $this->kernel->getContainer()->get('file_locator');
        $loaders = array(
            new XmlFileLoader($builder, $locator),
            new YamlFileLoader($builder, $locator),
            new IniFileLoader($builder, $locator),
            new PhpFileLoader($builder, $locator),
            (class_exists(DirectoryLoader::class) ? new DirectoryLoader($builder, $locator) : null),
            new ClosureLoader($builder),
        );
        $loaders = array_filter($loaders);
        $resolver = new LoaderResolver($loaders);
        $loader = new DelegatingLoader($resolver);
        $this->kernel->registerContainerConfiguration($loader);
        return $builder;
    }
1203013
public function loadTemplate($path)
    {
        $tpl = new Template();

        $tpl->injectVariables($this->getVariables());
        $tpl->setViewName($path);
        $tpl->setConfig("allow_debug", $this->getConfig("allow_debug"));
        $tpl->setConfig("layout", $this->getConfig("layout"));

        return $tpl->compile();
    }
719610
protected function getTwig()
    {
        $options = [
            'cache' => false,
            'strict_variables' => true,
        ];

        $loader = new \Twig_Loader_Filesystem();
        $loader->setPaths($this->skeletonDirs);

        return new \Twig_Environment($loader, $options);
    }
1367595
private function buildLoader($loader)
    {
        if ($loader instanceof TemplateLoaderInterface || is_callable($loader)) {
            return $loader;
        }

        if (is_string($loader) && is_subclass_of($loader, TemplateLoaderInterface::class, true)) {
            return function () use ($loader) {
                return new $loader();
            };
        }
    }
699152
private function getTemplate()
    {
        if ($this->template) {
            return $this->template;
        }

        return $this->template = $this->twig->load('@EkynaCms/Editor/Block/tabs.html.twig');
    }
1223845
private function generateTemplatesCache()
    {
        /** @var \Twig_Loader_Filesystem $loader */
        $loader = $this->tpl->getLoader();
        $availablePaths = $loader->getPaths();
        if (!empty($availablePaths)) {
            foreach ($availablePaths as $path) {
                $this->generateTemplate($path);
            }
        }
    }
1108112
public function registerTwig()
    {
        \Twig_Autoloader::register();

        $loader = new \Twig_Loader_Filesystem($_SERVER['DOCUMENT_ROOT'].'/../src/' . $this->app->getProjectName() . '/View');

        $twig = new \Twig_Environment($loader, array(
            'cache'       => $_SERVER['DOCUMENT_ROOT'].'/../app/cache/twig',
            'auto_reload' => true
        ));

        return $twig;
    }
1176598
public function getTwig()
    {
        if (!$this->twig) {
            Twig_Autoloader::register();
            $this->twig_loader = new Twig_Loader_Filesystem($this->base_view_path);

            $this->twig = new Twig_Environment(
                $this->twig_loader,
                $this->loader_configs
            );
        }

        return $this->twig;
    }
271781
public function createTwigEnvironmentBuilder()
    {
        $this->ensureCsrfTokenManagerAndTranslatorExist();
        $builder = new TwigEnvironmentBuilder();
        return $builder->setCsrfTokenManager($this->csrf_token_manager)->setTranslator($this->translator);
    }
481633
public function load($template)
    {
        $template = $this->findFirstExistingTemplate($template);
        if (!isset($this->loadedTemplates[ $template ])) {
            $class = $this->getTemplateClassName($template);

            $this->loadedTemplates[ $template ] = new $class($this);
            if (!$this->loadedTemplates[ $template ] instanceof Template) {
                throw new TemplatingException("The compiled class for {$template} is invalid");
            }
        }

        return $this->loadedTemplates[ $template ];
    }
983338
protected function getLoader(): LoaderInterface
    {
        if (! $this->loader instanceof LoaderInterface) {
            $this->loader = new CacheLoader(sprintf(
                '%s/%s.php',
                rtrim($this->getCacheLocation(), '/'),
                $this->getCacheFilename()
            ));
        }

        return $this->loader;
    }
426357
public function getLoader()
    {
        if (!$this->loader) {
            $this->loader = new TwigFilesystemLoader(
                $this->packageFinder,
                $this->dumpPaths(),
                $this->config->get('path_separator')
            );
        }

        return $this->loader;
    }