summaryrefslogtreecommitdiff
path: root/src/Renderer/TwigLoader.php
blob: f20a8764146ed7702a0c49db698160bad081f15a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php

namespace Engelsystem\Renderer;

use Twig_Error_Loader;
use Twig_Loader_Filesystem as FilesystemLoader;

class TwigLoader extends FilesystemLoader
{
    /**
     * @param string $name
     * @param bool   $throw
     * @return false|string
     * @throws Twig_Error_Loader
     */
    public function findTemplate($name, $throw = true)
    {
        $extension = '.twig';
        $extensionLength = mb_strlen($extension);
        if (mb_substr($name, -$extensionLength, $extensionLength) !== $extension) {
            $name .= $extension;
        }

        return parent::findTemplate($name, $throw);
    }
}