Skip to content

Commit

Permalink
fix phpstan issues
Browse files Browse the repository at this point in the history
  • Loading branch information
solverat committed Sep 8, 2023
1 parent 70b9e6b commit 065938a
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 21 deletions.
58 changes: 45 additions & 13 deletions docs/OutputWorkflow/10_EmailChannel.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. |

***

Expand Down Expand Up @@ -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).
Expand Down Expand Up @@ -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'] : '';
Expand All @@ -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
<?php

namespace App\MailEditor\Parser\TemplateParser;

class MySpecialParser implements TemplateParserInterface
{
public function supports(string $layoutType, string $layout): bool
{
return $layoutType === 'text';
}

public function parse(string $template): string
{
return str_replace(['<br />', '<br>'], "\n", $template);
}
}
```
2 changes: 1 addition & 1 deletion src/Controller/Admin/MailEditorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function getMailEditorDataAction(Request $request): JsonResponse
}
}

if (count($fieldConfig) > 0) {
if (count($children) > 0) {
$fieldConfig['children'] = $children;
}

Expand Down
1 change: 0 additions & 1 deletion src/MailEditor/Widget/FormFieldWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
5 changes: 0 additions & 5 deletions src/Migrations/Version20230830183642.php
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace DachcomBundle\Test\HAcceptance\ConditionalLogic\Condition;
namespace DachcomBundle\Test\Acceptance\ConditionalLogic\Condition;

use DachcomBundle\Test\Support\AcceptanceTester;
use DachcomBundle\Test\Support\Util\TestFormBuilder;
Expand Down

0 comments on commit 065938a

Please sign in to comment.