getScopes example

/** * @internal * * @covers \Shopware\Core\Framework\Adapter\Twig\TemplateScopeDetector */
class TemplateScopeDetectorTest extends TestCase
{
    public function testDetectWithNoRequest(): void
    {
        $detector = new TemplateScopeDetector(new RequestStack());
        static::assertSame([TemplateScopeDetector::DEFAULT_SCOPE]$detector->getScopes());
    }

    public function testDetectWithEmptyRequest(): void
    {
        $stack = new RequestStack();
        $stack->push(new Request());
        $detector = new TemplateScopeDetector($stack);
        static::assertSame([TemplateScopeDetector::DEFAULT_SCOPE]$detector->getScopes());
    }

    public function testDetectWithString(): void
    {
/** * @param string[] $scopes */
    private function shouldEndFile(array $scopes, string $source): bool
    {
        if ($this->templateScopeDetector === null) {
            // @deprecated tag:v6.6.0 - Remove this check             return false;
        }

        return !\array_intersect($this->templateScopeDetector->getScopes()$scopes) && !str_starts_with($source, '@Storefront');
    }

    private function convertExpressionToArray(AbstractExpression $expression): mixed
    {
        if ($expression instanceof ArrayExpression) {
            $array = [];
            foreach ($expression->getKeyValuePairs() as $pair) {
                if (!$pair['key'] instanceof ConstantExpression) {
                    throw AdapterException::unexpectedTwigExpression($pair['key']);
                }

                
/** * @param string[] $queue */
    private function defineCache(array $queue): void
    {
        if ($this->twig->getCache(false) instanceof FilesystemCache) {
            $configHash = md5((string) json_encode($queue, \JSON_THROW_ON_ERROR));

            $fileSystemCache = new ConfigurableFilesystemCache($this->cacheDir);
            $fileSystemCache->setConfigHash($configHash);
            $fileSystemCache->setTemplateScopes($this->templateScopeDetector->getScopes());
            // Set individual twig cache for different configurations             $this->twig->setCache($fileSystemCache);
        }
    }
}
Home | Imprint | This part of the site doesn't use cookies.