Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
strategy:
fail-fast: false
matrix:
version-selection: [ 'lowest', 'highest']
version-selection: [ 'highest' ]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"shopware/core": "~6.5.0 || ~6.6.0 || ~6.7.0"
},
"scripts": {
"format": "docker run --rm -v $(pwd):/ext ghcr.io/shopwarelabs/extension-verifier:latest format /ext",
"check": "docker run --rm -v $(pwd):/ext ghcr.io/shopwarelabs/extension-verifier:latest check /ext"
"format": "docker run --rm -v $(pwd):/ext shopware/shopware-cli:latest extension format /ext",
"check": "docker run --rm -v $(pwd):/ext shopware/shopware-cli:latest extension validate --full /ext"
}
}
1 change: 1 addition & 0 deletions src/Command/ExportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public function execute(InputInterface $input, OutputInterface $output): int
$targetFile = \sprintf('%s/%s.twig', $templateDir, $name);
}

// @phpstan-ignore-next-line
$fs->dumpFile($targetFile, $record[$field]);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,99 +1,100 @@
{% block sw_mail_template_list_grid %}
<sw-card
:title="$tc('sw-mail-template.list.titleMailTemplateList')"
position-identifier="sw-mail-template-list"
>
<template>
{% block sw_mail_template_list_grid_empty_state %}
<sw-empty-state
v-if="!isLoading && !showListing"
:title="$tc('sw-mail-template.list.emptyStateTitle')"
:subline="$tc('sw-mail-template.list.emptyStateSubTitle')"
:absolute="false"
>
{% block sw_mail_template_list_grid_empty_state_icon %}
<template #icon>
<img
:src="'/administration/static/img/empty-states/settings-empty-state.svg' | asset"
alt
/>
</template>
{% endblock %}
</sw-empty-state>
<sw-card
:title="$tc('sw-mail-template.list.titleMailTemplateList')"
position-identifier="sw-mail-template-list"
>
<template>
{% block sw_mail_template_list_grid_empty_state %}
<sw-empty-state
v-if="!isLoading && !showListing"
:title="$tc('sw-mail-template.list.emptyStateTitle')"
:subline="$tc('sw-mail-template.list.emptyStateSubTitle')"
:absolute="false"
>
{% block sw_mail_template_list_grid_empty_state_icon %}
<template #icon>
<img
:src="'/administration/static/img/empty-states/settings-empty-state.svg' | asset"
alt
/>
</template>
{% endblock %}
</template>
</sw-empty-state>
{% endblock %}
</template>

<template #grid>
<sw-entity-listing
v-if="isLoading || showListing"
id="mailTemplateGrid"
class="sw-mail-templates-list-grid"
detail-route="sw.mail.template.detail"
identifier="sw-mail-template-list"
:items="mailTemplates"
:columns="getListColumns()"
:repository="mailTemplateRepository"
:full-page="false"
:is-loading="isLoading"
:allow-view="acl.can('mail_templates.viewer')"
:allow-edit="acl.can('mail_templates.editor')"
:allow-delete="acl.can('mail_templates.deleter')"
:show-selection="acl.can('mail_templates.deleter')"
:skeleton-item-amount="skeletonItemAmount"
@update-records="updateRecords"
>
{% block sw_mail_template_list_grid_columns_frosh_template_mail %}
<template #column-froshTemplateMail="{ item }">
<sw-label
appearance="circle"
:variant="item.extensions?.froshTemplateMail.subject ? 'success' : 'warning'"
v-tooltip="getFroshTooltip('subject', item.extensions.froshTemplateMail.subject)"
>
<sw-icon
name="regular-exclamation-s"
small
/>
</sw-label>
<sw-label
appearance="circle"
:variant="item.extensions?.froshTemplateMail.plain ? 'success' : 'warning'"
v-tooltip="getFroshTooltip('plain', item.extensions.froshTemplateMail.plain)"
>
<sw-icon
name="regular-align-left"
small
/>
</sw-label>
<sw-label
appearance="circle"
:variant="item.extensions?.froshTemplateMail.html ? 'success' : 'warning'"
v-tooltip="getFroshTooltip('html', item.extensions.froshTemplateMail.html)"
>
<sw-icon
name="regular-code"
small
/>
</sw-label>
</template>
{% endblock %}
<template #grid>
<sw-entity-listing
v-if="isLoading || showListing"
id="mailTemplateGrid"
class="sw-mail-templates-list-grid"
detail-route="sw.mail.template.detail"
identifier="sw-mail-template-list"
:items="mailTemplates"
:columns="getListColumns()"
:repository="mailTemplateRepository"
:full-page="false"
:is-loading="isLoading"
:allow-view="acl.can('mail_templates.viewer')"
:allow-edit="acl.can('mail_templates.editor')"
:allow-delete="acl.can('mail_templates.deleter')"
:show-selection="acl.can('mail_templates.deleter')"
:skeleton-item-amount="skeletonItemAmount"
@update-records="updateRecords"
>
{% block sw_mail_template_list_grid_columns_frosh_template_mail %}
<template #column-froshTemplateMail="{ item }">
<sw-label
appearance="circle"
:variant="item.extensions?.froshTemplateMail.subject ? 'success' : 'warning'"
v-tooltip="getFroshTooltip('subject', item.extensions.froshTemplateMail.subject)"
>
<sw-icon
name="regular-exclamation-s"
small
/>
</sw-label>
<sw-label
appearance="circle"
:variant="item.extensions?.froshTemplateMail.plain ? 'success' : 'warning'"
v-tooltip="getFroshTooltip('plain', item.extensions.froshTemplateMail.plain)"
>
<sw-icon
name="regular-align-left"
small
/>
</sw-label>
<sw-label
appearance="circle"
:variant="item.extensions?.froshTemplateMail.html ? 'success' : 'warning'"
v-tooltip="getFroshTooltip('html', item.extensions.froshTemplateMail.html)"
>
<sw-icon
name="regular-code"
small
/>
</sw-label>
</template>
{% endblock %}

{% block sw_mail_template_list_grid_columns_technical_name %}
<template #column-technicalName="{ item }">
{{ item.extensions.froshTemplateMail.technicalName }}
</template>
<template #column-technicalName="{ item }">
{{ item.extensions.froshTemplateMail.technicalName }}
</template>
{% endblock %}

<template #more-actions="{ item }">
{% block sw_mail_template_list_grid_columns_actions_duplicate %}
<sw-context-menu-item
class="sw-mail-template-list-grid__duplicate-action"
:disabled="!acl.can('mail_templates.creator')"
@click="onDuplicate(item.id)"
>
{{ $tc('sw-mail-template.list.contextMenuDuplicate') }}
</sw-context-menu-item>
{% endblock %}
<template #more-actions="{ item }">
{% block sw_mail_template_list_grid_columns_actions_duplicate %}
<sw-context-menu-item
class="sw-mail-template-list-grid__duplicate-action"
:disabled="!acl.can('mail_templates.creator')"
@click="onDuplicate(item.id)"
>
{{ $tc('sw-mail-template.list.contextMenuDuplicate') }}
</sw-context-menu-item>
{% endblock %}
</template>
</sw-entity-listing>
</template>
</sw-card>
</template>
</sw-entity-listing>
</template>
</sw-card>
{% endblock %}
Original file line number Diff line number Diff line change
@@ -1,45 +1,47 @@
{% block sw_mail_template_options_form_subject_field %}
{% parent() %}
{% parent() %}

<sw-label
v-if="mailTemplate.extensions.froshTemplateMail"
appearance="circle"
:variant="mailTemplate.extensions.froshTemplateMail.subject ? 'success' : 'warning'"
v-tooltip="getFroshTooltip('subject', mailTemplate.extensions.froshTemplateMail.subject)"
>
<sw-icon
name="regular-exclamation-s"
small
/>
</sw-label>
<sw-label
v-if="mailTemplate.extensions.froshTemplateMail"
appearance="circle"
:variant="mailTemplate.extensions.froshTemplateMail.subject ? 'success' : 'warning'"
v-tooltip="getFroshTooltip('subject', mailTemplate.extensions.froshTemplateMail.subject)"
>
<sw-icon
name="regular-exclamation-s"
small
/>
</sw-label>
{% endblock %}

{% block sw_mail_template_mail_text_form_content_plain_field %}
{% parent() %}
{% parent() %}

<sw-label
v-if="mailTemplate.extensions.froshTemplateMail"
appearance="circle"
:variant="mailTemplate.extensions.froshTemplateMail.plain ? 'success' : 'warning'"
v-tooltip="getFroshTooltip('plain', mailTemplate.extensions.froshTemplateMail.plain)"
>
<sw-icon
name="regular-align-left"
small
/>
</sw-label>
<sw-label
v-if="mailTemplate.extensions.froshTemplateMail"
appearance="circle"
:variant="mailTemplate.extensions.froshTemplateMail.plain ? 'success' : 'warning'"
v-tooltip="getFroshTooltip('plain', mailTemplate.extensions.froshTemplateMail.plain)"
>
<sw-icon
name="regular-align-left"
small
/>
</sw-label>
{% endblock %}

{% block sw_mail_template_mail_text_form_content_html_field %}
{% parent() %}
{% parent() %}

<sw-label
v-if="mailTemplate.extensions.froshTemplateMail"
appearance="circle"
:variant="mailTemplate.extensions.froshTemplateMail.html ? 'success' : 'warning'"
v-tooltip="getFroshTooltip('html', mailTemplate.extensions.froshTemplateMail.html)"
>
<sw-icon
name="regular-code"
small
/>
</sw-label>
<sw-label
v-if="mailTemplate.extensions.froshTemplateMail"
appearance="circle"
:variant="mailTemplate.extensions.froshTemplateMail.html ? 'success' : 'warning'"
v-tooltip="getFroshTooltip('html', mailTemplate.extensions.froshTemplateMail.html)"
>
<sw-icon
name="regular-code"
small
/>
</sw-label>
{% endblock %}
29 changes: 27 additions & 2 deletions src/Services/StringTemplateRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

namespace Frosh\TemplateMail\Services;

use Shopware\Core\Framework\Adapter\Twig\Exception\StringTemplateRenderingException;
use Shopware\Core\Framework\Context;
use Symfony\Component\DependencyInjection\Attribute\AsDecorator;
use Twig\Environment;
use Twig\Error\Error;
use Twig\Error\SyntaxError;
use Twig\Extension\CoreExtension;
use Twig\Extension\EscaperExtension;
use Twig\Loader\ArrayLoader;
use Twig\Loader\ChainLoader;

Expand Down Expand Up @@ -68,11 +69,35 @@ public function render(string $templateSource, array $data, Context $context, bo

$this->twig->addGlobal('context', $context);

if ($this->twig->hasExtension(EscaperExtension::class)) {
/** @var EscaperExtension $escaperExtension */
$escaperExtension = $this->twig->getExtension(EscaperExtension::class);
$escaperExtension->setDefaultStrategy($htmlEscape ? 'html' : false);
}

if ($this->twig->hasExtension(CoreExtension::class) && \array_key_exists('timezone', $data) && $data['timezone'] !== null) {
$coreExtension = $this->twig->getExtension(CoreExtension::class);
$timezone = $data['timezone'];

if (\is_string($timezone) || $timezone instanceof \DateTimeZone) {
$coreExtension->setTimezone($timezone);
}
}

try {
return $this->twig->render($name, $data);
} catch (Error $error) {
// @phpstan-ignore-next-line
throw new StringTemplateRenderingException($error->getMessage());
if (class_exists(\Shopware\Core\Framework\Adapter\AdapterException::class) && method_exists(\Shopware\Core\Framework\Adapter\AdapterException::class, 'invalidTemplateSyntax')) {
if ($error instanceof SyntaxError) {
throw \Shopware\Core\Framework\Adapter\AdapterException::invalidTemplateSyntax($error->getMessage());
}

throw \Shopware\Core\Framework\Adapter\AdapterException::renderingTemplateFailed($error->getMessage());
} else {
// @phpstan-ignore-next-line
throw new \Shopware\Core\Framework\Adapter\Twig\Exception\StringTemplateRenderingException($error->getMessage());
}
}
}

Expand Down
35 changes: 0 additions & 35 deletions src/Services/StringTemplateRenderingException.php

This file was deleted.

Loading