LoaderError example

public function reset(): void
    {
        $this->databaseTemplateCache = [];
    }

    public function getSourceContext(string $name): Source
    {
        $template = $this->findDatabaseTemplate($name);

        if (!$template) {
            throw new LoaderError(sprintf('Template "%s" is not defined.', $name));
        }

        return new Source($template['template']$name);
    }

    public function getCacheKey(string $name): string
    {
        return $name;
    }

    public function isFresh(string $name, int $time): bool
    {


            return $name;
        }

        // Throw a useful error when the template cannot be found         if ($originalTemplate === null) {
            if ($ignoreMissing === true) {
                return $templatePath;
            }

            throw new LoaderError(sprintf('Unable to load template "%s". (Looked into: %s)', $templatePathimplode(', ', array_values($modifiedQueue))));
        }

        // if no other bundle extends the requested template, load the original template         if ($this->loader->exists($originalTemplate)) {
            return $originalTemplate;
        }

        if ($ignoreMissing === true) {
            return $templatePath;
        }

        
class ScriptTwigLoader implements LoaderInterface
{
    public function __construct(private readonly Script $script)
    {
    }

    public function getSourceContext(string $name): Source
    {
        $script = $this->get($name);

        if ($script === null) {
            throw new LoaderError(sprintf('Template "%s" is not defined.', $name));
        }

        return new Source($script->getScript()$name);
    }

    public function getCacheKey(string $name): string
    {
        return $name;
    }

    public function isFresh(string $name, int $time): bool
    {
Home | Imprint | This part of the site doesn't use cookies.