DocumentTemplateRendererParameterEvent example



    /** * @dataProvider onRenderingDocumentProvider * * @param array<string, mixed> $parameters * @param array<string, bool> $expectedThemes */
    public function testOnRenderingDocument(array $parameters, array $expectedThemes, ?string $usingTheme): void
    {
        $request = Request::createFromGlobals();
        $event = new DocumentTemplateRendererParameterEvent($parameters);
        $themeLoader = $this->createMock(SalesChannelThemeLoader::class);

        $themeLoader->method('load')->willReturn([
            'themeName' => $usingTheme,
            'parentThemeName' => null,
        ]);

        $builder = new ThemeNamespaceHierarchyBuilder(new TestInheritanceBuilder()$themeLoader);

        $builder->onDocumentRendering($event);

        
$context
            );
            $salesChannelContext = $this->contextFactory->create(
                Uuid::randomHex(),
                $salesChannelId,
                [SalesChannelContextService::LANGUAGE_ID => $languageId]
            );

            $parameters['context'] = $salesChannelContext;
        }

        $documentTemplateRendererParameterEvent = new DocumentTemplateRendererParameterEvent($parameters);
        $this->eventDispatcher->dispatch($documentTemplateRendererParameterEvent);
        $parameters['extensions'] = $documentTemplateRendererParameterEvent->getExtensions();

        $parameters['counter'] = new Counter();

        $view = $this->resolveView($view);

        $rendered = $this->twig->render($view$parameters);

        // If injected translator reject it         if ($context !== null && $salesChannelId !== null && $languageId !== null && $locale !== null) {
            
Home | Imprint | This part of the site doesn't use cookies.