templateBodyNotSet example

/** * @param array<string, mixed> $data */
    public function renderBody(
        ProductExportEntity $productExport,
        SalesChannelContext $salesChannelContext,
        array $data
    ): string {
        $bodyTemplate = $productExport->getBodyTemplate();
        if (!\is_string($bodyTemplate)) {
            throw ProductExportException::templateBodyNotSet();
        }

        try {
            $content = $this->templateRenderer->render(
                $bodyTemplate,
                $data,
                $salesChannelContext->getContext()
            ) . \PHP_EOL;

            return $this->replaceSeoUrlPlaceholder($content$productExport$salesChannelContext);
        } catch (StringTemplateRenderingException $exception) {
            
use Symfony\Component\HttpFoundation\Response;

/** * @internal * * @covers \Shopware\Core\Content\ProductExport\ProductExportException */
class ProductExportExceptionTest extends TestCase
{
    public function testTemplateBodyNotSet(): void
    {
        $exception = ProductExportException::templateBodyNotSet();
        static::assertSame(Response::HTTP_BAD_REQUEST, $exception->getStatusCode());
        static::assertSame('PRODUCT_EXPORT__TEMPLATE_BODY_NOT_SET', $exception->getErrorCode());

        static::expectException(ProductExportException::class);

        throw $exception;
    }

    /** * @DisabledFeatures(features={"v6.6.0.0"}) */
    
Home | Imprint | This part of the site doesn't use cookies.