From 065938ab92a05c46cec89b32eabebe9c2a5ba944 Mon Sep 17 00:00:00 2001 From: Stefan Hagspiel Date: Fri, 8 Sep 2023 13:25:48 +0200 Subject: [PATCH] fix phpstan issues --- docs/OutputWorkflow/10_EmailChannel.md | 58 ++++++++++++++----- src/Controller/Admin/MailEditorController.php | 2 +- src/MailEditor/Widget/FormFieldWidget.php | 1 - src/Migrations/Version20230830183642.php | 5 -- .../Action/AbstractActionCest.php | 2 +- 5 files changed, 47 insertions(+), 21 deletions(-) diff --git a/docs/OutputWorkflow/10_EmailChannel.md b/docs/OutputWorkflow/10_EmailChannel.md index 1fe60938..b6797e2d 100644 --- a/docs/OutputWorkflow/10_EmailChannel.md +++ b/docs/OutputWorkflow/10_EmailChannel.md @@ -10,13 +10,13 @@ There is also a `Default` fallback field. If a requested locale can't be found d ## Available Options -| Name | Type | Description | -|------|-------------|-------------| -| Mail Template | Pimcore Mail Type | Use it to define the mail template via drag'n'drop. | -| Ignored Field in Email | Tags | In some cases, you don't want to send specific fields via mail. For example, if you send a copy to the user. Add one or multiple fields as string. *Notice:* The field name needs be identical to the field name in your form configuration. | -| Allow Attachment | Checkbox | If this is checked, attachments or attachments-links will be appended to the mail. | -| Force Plain Text Submission | Checkbox | If you want to force the plain text submission, you need to check this option. Read more about the submission types [below](./10_EmailChannel.md#mail-submission-types). | -| Required By | Checkbox | If this is checked, you need to add your own data to the mail template. You can use all the field names as placeholder. This function is only necessary in rare cases. | +| Name | Type | Description | +|-----------------------------|-------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Mail Template | Pimcore Mail Type | Use it to define the mail template via drag'n'drop. | +| Ignored Field in Email | Tags | In some cases, you don't want to send specific fields via mail. For example, if you send a copy to the user. Add one or multiple fields as string. *Notice:* The field name needs be identical to the field name in your form configuration. | +| Allow Attachment | Checkbox | If this is checked, attachments or attachments-links will be appended to the mail. | +| Force Plain Text Submission | Checkbox | If you want to force the plain text submission, you need to check this option. Read more about the submission types [below](./10_EmailChannel.md#mail-submission-types). | +| Required By | Checkbox | If this is checked, you need to add your own data to the mail template. You can use all the field names as placeholder. This function is only necessary in rare cases. | *** @@ -62,15 +62,14 @@ You'll find all available options directly on GitHub via [thephpleague/html-to-m *** ## Mail Layout Editor +https://user-images.githubusercontent.com/700119/266572709-6367f49b-9f86-4d5a-8029-45067d629733.png -![](http://g.recordit.co/OJ7uM6FxY0.gif) - -> **Attention**: This mail layout editor does not respect any special mail template language (like inky)! - ## Things to know - Always save your form before opening the mail editor -## Custom Service +*** + +## Custom Widget Use the mail editor to specify some special mail templates. It's very easy to add some custom template widgets (Eg. date field). @@ -114,7 +113,7 @@ class DateWidget implements MailEditorWidgetInterface ]; } - public function getValueForOutput(array $config) + public function getValueForOutput(array $config, string $layoutType) { $form = $config['form']; $link = isset($config['link']) ? $config['link'] : ''; @@ -123,3 +122,36 @@ class DateWidget implements MailEditorWidgetInterface } } ``` + +## Template Parser + +### Build-In Parser +- Inky Parser (Only available if emailizr has been installed) +- PlainText Parser + +### Custom Template Parser + +```yaml +App\MailEditor\Parser\TemplateParser\MySpecialParser: + tags: + - { name: form_builder.mail_editor.template_parser } +``` + +```php +', '
'], "\n", $template); + } +} +``` \ No newline at end of file diff --git a/src/Controller/Admin/MailEditorController.php b/src/Controller/Admin/MailEditorController.php index ee4b5228..95ac2000 100644 --- a/src/Controller/Admin/MailEditorController.php +++ b/src/Controller/Admin/MailEditorController.php @@ -95,7 +95,7 @@ public function getMailEditorDataAction(Request $request): JsonResponse } } - if (count($fieldConfig) > 0) { + if (count($children) > 0) { $fieldConfig['children'] = $children; } diff --git a/src/MailEditor/Widget/FormFieldWidget.php b/src/MailEditor/Widget/FormFieldWidget.php index f0ccde82..cb732ce9 100644 --- a/src/MailEditor/Widget/FormFieldWidget.php +++ b/src/MailEditor/Widget/FormFieldWidget.php @@ -9,7 +9,6 @@ class FormFieldWidget implements MailEditorWidgetInterface, MailEditorFieldDataWidgetInterface { private const RENDER_TYPE_LABEL = 'L'; - private const RENDER_TYPE_VALUE = 'V'; public function __construct(protected TranslatorInterface $translator) { diff --git a/src/Migrations/Version20230830183642.php b/src/Migrations/Version20230830183642.php index 73bee944..1c18532c 100644 --- a/src/Migrations/Version20230830183642.php +++ b/src/Migrations/Version20230830183642.php @@ -103,11 +103,6 @@ protected function parseSquareBracketsTag(array $tag): ?string $type = $tag[1]; $config = $this->parseSquareBracketsAttributes($tag[2]); - // add field value to widget. - if (isset($config['sub-type'], $this->outputData[$config['sub-type']])) { - $config['outputData'] = $this->outputData[$config['sub-type']]; - } - $cleanConfig = []; foreach ($config as $key => $value) { if ($value === 'true' || $value === 'false') { diff --git a/tests/Acceptance/ConditionalLogic/Action/AbstractActionCest.php b/tests/Acceptance/ConditionalLogic/Action/AbstractActionCest.php index 6d9d49b3..5cc1b361 100644 --- a/tests/Acceptance/ConditionalLogic/Action/AbstractActionCest.php +++ b/tests/Acceptance/ConditionalLogic/Action/AbstractActionCest.php @@ -1,6 +1,6 @@