dontHaveTwigInjected example

public function testUnSupportStorefrontResponse(): void
    {
        $res = StorefrontException::unSupportStorefrontResponse();

        static::assertEquals(500, $res->getStatusCode());
        static::assertEquals('STOREFRONT__UN_SUPPORT_STOREFRONT_RESPONSE', $res->getErrorCode());
        static::assertEquals('Symfony render implementation changed. Providing a response is no longer supported', $res->getMessage());
    }

    public function testDontHaveTwigInjected(): void
    {
        $res = StorefrontException::dontHaveTwigInjected('Example\Class');

        static::assertEquals(500, $res->getStatusCode());
        static::assertEquals('STOREFRONT__CLASS_DONT_HAVE_TWIG_INJECTED', $res->getErrorCode());
        static::assertEquals('Class Example\Class does not have twig injected. Add to your service definition a method call to setTwig with the twig instance', $res->getMessage());
    }
}

        $view = $this->getTemplateFinder()->find($view);

        if ($this->twig !== null) {
            try {
                return $this->twig->render($view$parameters);
            } catch (LoaderError|RuntimeError|SyntaxError $e) {
                throw StorefrontException::cannotRenderView($view$e->getMessage()$parameters);
            }
        }

        throw StorefrontException::dontHaveTwigInjected(static::class);
    }

    protected function getTemplateFinder(): TemplateFinder
    {
        return $this->container->get(TemplateFinder::class);
    }

    protected function hook(Hook $hook): void
    {
        $this->container->get(ScriptExecutor::class)->execute($hook);
    }

    
Home | Imprint | This part of the site doesn't use cookies.