enableTestMode example

return new JsonResponse(null, Response::HTTP_NO_CONTENT);
    }

    #[Route(path: '/api/_action/mail-template/build', name: 'api.action.mail_template.build', methods: ['POST'])]     public function build(RequestDataBag $post, Context $context): JsonResponse
    {
        $contents = [];
        $data = $post->all();
        $templateData = $data['mailTemplateType']['templateData'];

        $this->templateRenderer->enableTestMode();
        $contents['text/html'] = $this->templateRenderer->render($data['mailTemplate']['contentHtml']$templateData$context);
        $this->templateRenderer->disableTestMode();

        return new JsonResponse($contents['text/html']);
    }
}


            $this->eventDispatcher->dispatch($event);
            $this->logger->error(
                'senderMail not configured for salesChannel: ' . $salesChannelId . '. Please check system_config \'core.basicInformation.email\'',
                $templateData
            );
        }

        $contents = $this->buildContents($data$salesChannel);
        if ($this->isTestMode($data)) {
            $this->templateRenderer->enableTestMode();
            if (\is_array($templateData['order'] ?? []) && empty($templateData['order']['deepLinkCode'])) {
                $templateData['order']['deepLinkCode'] = 'home';
            }
        }
        $template = $data['subject'];

        try {
            $data['subject'] = $this->templateRenderer->render($template$templateData$context, false);
            $template = $data['senderName'];
            $data['senderName'] = $this->templateRenderer->render($template$templateData$context, false);
            foreach ($contents as $index => $template) {
                
Home | Imprint | This part of the site doesn't use cookies.