Skip to content

Commit

Permalink
Add possibility to custom path twig template to render
Browse files Browse the repository at this point in the history
  • Loading branch information
Xorg committed Aug 31, 2023
1 parent eab1515 commit 349f604
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,21 @@ It set automatique but you can custom
emails: Partial\emails\
save_notify: true # by default true mean all notification send will be save in Db messenger
```

it's away possible to custom path twig template to render !

```
as you can see in code if you setTemplate() to what eve "xxx/xxxx/xxx.tmh.twig it will set.
// try to fund way to be able to have custom path to template
// $option->getTemplate() == "default" ; null ; "xxxx/xxxxx/default.html.twig"
$value = $option->getTemplate();
$Template = match (true) {
str_contains($value, '/') => $value,
default => $this->neoxTemplate['emails'] . "/" . ($option->getTemplate() ? : 'default'). '.html.twig',
};
```

## How to use ?
```php
myController.php
Expand Down
12 changes: 10 additions & 2 deletions src/notify/EmailCustomer.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,17 @@ public function asEmailMessage(EmailRecipientInterface $recipient, string $trans
* markAsPublic() take all annotation symfony.
* !!! neox_[xxxx] SETTING FOR TWIG PREFIX !!! >> $option->setContext
*/


// try to fund way to be able to have custom path to template
// $option->getTemplate() == "default" ; null ; "xxxx/xxxxx/default.html.twig"
$value = $option->getTemplate();
$Template = match (true) {
str_contains($value, '/') => $value,
default => $this->neoxTemplate['emails'] . "/" . ($option->getTemplate() ? : 'default'). '.html.twig',
};

$email = $message->getMessage()->markAsPublic();
$email->htmlTemplate( $this->neoxTemplate['emails'] . "/" . ($option->getTemplate() ? : 'default'). '.html.twig' );
$email->htmlTemplate( $Template );
$option->setContext("subject",$option->getSubject());
$option->setContext("content",$option->getContent());

Expand Down

0 comments on commit 349f604

Please sign in to comment.