vendor/symfony/twig-bridge/Mime/TemplatedEmail.php line 19

  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <[email protected]>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Bridge\Twig\Mime;
  11. use Symfony\Component\Mime\Email;
  12. /**
  13.  * @author Fabien Potencier <[email protected]>
  14.  */
  15. class TemplatedEmail extends Email
  16. {
  17.     private ?string $htmlTemplate null;
  18.     private ?string $textTemplate null;
  19.     private array $context = [];
  20.     /**
  21.      * @return $this
  22.      */
  23.     public function textTemplate(?string $template): static
  24.     {
  25.         $this->textTemplate $template;
  26.         return $this;
  27.     }
  28.     /**
  29.      * @return $this
  30.      */
  31.     public function htmlTemplate(?string $template): static
  32.     {
  33.         $this->htmlTemplate $template;
  34.         return $this;
  35.     }
  36.     public function getTextTemplate(): ?string
  37.     {
  38.         return $this->textTemplate;
  39.     }
  40.     public function getHtmlTemplate(): ?string
  41.     {
  42.         return $this->htmlTemplate;
  43.     }
  44.     /**
  45.      * @return $this
  46.      */
  47.     public function context(array $context): static
  48.     {
  49.         $this->context $context;
  50.         return $this;
  51.     }
  52.     public function getContext(): array
  53.     {
  54.         return $this->context;
  55.     }
  56.     public function isRendered(): bool
  57.     {
  58.         return null === $this->htmlTemplate && null === $this->textTemplate;
  59.     }
  60.     public function markAsRendered(): void
  61.     {
  62.         $this->textTemplate null;
  63.         $this->htmlTemplate null;
  64.         $this->context = [];
  65.     }
  66.     /**
  67.      * @internal
  68.      */
  69.     public function __serialize(): array
  70.     {
  71.         return [$this->htmlTemplate$this->textTemplate$this->contextparent::__serialize()];
  72.     }
  73.     /**
  74.      * @internal
  75.      */
  76.     public function __unserialize(array $data): void
  77.     {
  78.         [$this->htmlTemplate$this->textTemplate$this->context$parentData] = $data;
  79.         parent::__unserialize($parentData);
  80.     }
  81. }