Lines
87.50%
21 / 24
Methods
80.00%
4 / 5
Classes
0.00%
0 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| getProviderId | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| getTemplate | 0.00% | 0 / 3 | 0.00% | 0 / 1 | 6 | ||
| getTemplates | 100.00% | 3 / 3 | 100.00% | 1 / 1 | 2 | ||
| loadTemplates | 100.00% | 16 / 16 | 100.00% | 1 / 1 | 2 | ||
| 5 | class MailTemplateProvider | |
| 6 | { | |
| 7 | protected $templates = false; | |
| 8 | protected $process; | |
| 9 | ||
| 10 | public function __construct($process) | |
| 11 | { | |
| 12 | $this->process = $process; | |
| 13 | } | |
| 14 | ||
| 15 | protected function getProviderId() | |
| 16 | { | |
| 17 | return $this->process->scope->provider['id']; | |
| 18 | } | |
| 19 | ||
| 20 | /** @psalm-api */ | |
| 21 | public function getTemplate($templateName) | |
| 22 | { | |
| 23 | if (!$this->templates) { | |
| 24 | $this->loadTemplates(); | |
| 25 | } | |
| 26 | return $this->templates[$templateName]; | |
| 27 | } | |
| 28 | ||
| 29 | /** @psalm-api */ | |
| 30 | public function getTemplates() | |
| 31 | { | |
| 32 | if (!$this->templates) { | |
| 33 | $this->loadTemplates(); | |
| 34 | } | |
| 35 | return $this->templates; | |
| 36 | } | |
| 37 | ||
| 38 | protected function loadTemplates(): void | |
| 39 | { | |
| 40 | ||
| 41 | $this->templates = array( | |
| 42 | 'mail_queued.twig' => "template is empty", | |
| 43 | 'mail_confirmation.twig' => "template is empty", | |
| 44 | 'mail_reminder.twig' => "template is empty", | |
| 45 | 'mail_delete.twig' => "template is empty", | |
| 46 | 'mail_survey.twig' => "template is empty", | |
| 47 | 'mail_processlist_overview.twig' => "template is empty", | |
| 48 | 'mail_preconfirmed.twig' => "template is empty", | |
| 49 | 'icsappointment.twig' => "template is empty", | |
| 50 | 'icsappointment_delete.twig' => "template is empty", | |
| 51 | 'mail_admin_delete.twig' => "template is empty", | |
| 52 | 'mail_admin_update.twig' => "template is empty", | |
| 53 | ); | |
| 54 | ||
| 55 | ||
| 56 | $result = (new \BO\Zmsbackend\Mail\Service\MailTemplates())->readCustomizedListForProvider($this->getProviderId()); | |
| 57 | foreach ($result as $templateObject) { | |
| 58 | $this->templates[$templateObject['name']] = $templateObject['value']; | |
| 59 | } | |
| 60 | } | |
| 61 | } |