diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/controller/ContactFormController.php | 27 | ||||
| -rw-r--r-- | src/controller/PageManagementController.php | 17 | ||||
| -rw-r--r-- | src/controller/UserController.php | 6 | ||||
| -rw-r--r-- | src/model/entities/Email.php | 14 | ||||
| -rw-r--r-- | src/model/entities/EmailForm.php | 58 | ||||
| -rw-r--r-- | src/model/entities/Node.php | 10 | ||||
| -rw-r--r-- | src/model/entities/NodeData.php | 4 | ||||
| -rw-r--r-- | src/service/EmailService.php | 4 | ||||
| -rw-r--r-- | src/view/ShowEmailsBuilder.php | 2 |
9 files changed, 102 insertions, 40 deletions
diff --git a/src/controller/ContactFormController.php b/src/controller/ContactFormController.php index 6b89161..cbc1837 100644 --- a/src/controller/ContactFormController.php +++ b/src/controller/ContactFormController.php | |||
| @@ -4,13 +4,15 @@ | |||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | use Doctrine\ORM\EntityManager; | 6 | use Doctrine\ORM\EntityManager; |
| 7 | use App\Entity\EmailForm; | ||
| 8 | use App\Entity\Email; | ||
| 7 | use Symfony\Component\HttpFoundation\JsonResponse; | 9 | use Symfony\Component\HttpFoundation\JsonResponse; |
| 8 | 10 | ||
| 9 | class ContactFormController | 11 | class ContactFormController |
| 10 | { | 12 | { |
| 11 | static public function keepEmails(EntityManager $entityManager, array $json): JsonResponse | 13 | static public function keepEmails(EntityManager $entityManager, array $json): JsonResponse |
| 12 | { | 14 | { |
| 13 | $form_data = $entityManager->find('App\Entity\NodeData', $json['id']); | 15 | $form_data = $entityManager->find(EmailForm::class, $json['id']); |
| 14 | $form_data->updateData('keep_emails', $json['checked'] ? true : false); | 16 | $form_data->updateData('keep_emails', $json['checked'] ? true : false); |
| 15 | $entityManager->persist($form_data); | 17 | $entityManager->persist($form_data); |
| 16 | $entityManager->flush(); | 18 | $entityManager->flush(); |
| @@ -18,7 +20,7 @@ class ContactFormController | |||
| 18 | } | 20 | } |
| 19 | static public function setEmailsRetentionPeriod(EntityManager $entityManager, array $json): JsonResponse | 21 | static public function setEmailsRetentionPeriod(EntityManager $entityManager, array $json): JsonResponse |
| 20 | { | 22 | { |
| 21 | $form_data = $entityManager->find('App\Entity\NodeData', $json['id']); | 23 | $form_data = $entityManager->find(EmailForm::class, $json['id']); |
| 22 | $form_data->updateData($json['field'], (int)$json['months']); | 24 | $form_data->updateData($json['field'], (int)$json['months']); |
| 23 | $entityManager->persist($form_data); | 25 | $entityManager->persist($form_data); |
| 24 | $entityManager->flush(); | 26 | $entityManager->flush(); |
| @@ -28,22 +30,15 @@ class ContactFormController | |||
| 28 | { | 30 | { |
| 29 | $form = new FormValidation($json, 'email_params'); | 31 | $form = new FormValidation($json, 'email_params'); |
| 30 | 32 | ||
| 31 | $error = ''; | ||
| 32 | if($form->validate()){ | 33 | if($form->validate()){ |
| 33 | $form_data = $entityManager->find('App\Entity\NodeData', $json['id']); | 34 | $form_data = $entityManager->find(EmailForm::class, $json['id']); |
| 34 | $form_data->updateData($json['what_param'], trim($json['value'])); | 35 | $form_data->updateData($json['what_param'], trim($json['value'])); |
| 35 | $entityManager->persist($form_data); | 36 | $entityManager->persist($form_data); // ?? |
| 36 | $entityManager->flush(); | 37 | $entityManager->flush(); |
| 37 | } | ||
| 38 | else{ | ||
| 39 | $error = $form->getErrors()[0]; // la 1ère erreur sera affichée | ||
| 40 | } | ||
| 41 | |||
| 42 | if(empty($error)){ | ||
| 43 | return new JsonResponse(['success' => true]); | 38 | return new JsonResponse(['success' => true]); |
| 44 | } | 39 | } |
| 45 | else{ | 40 | else{ |
| 46 | return new JsonResponse(['success' => false, 'error' => $error]); | 41 | return new JsonResponse(['success' => false, 'error' => $form->getErrors()[0]]); // la 1ère erreur sera affichée |
| 47 | } | 42 | } |
| 48 | } | 43 | } |
| 49 | 44 | ||
| @@ -55,7 +50,7 @@ class ContactFormController | |||
| 55 | $error = ''; | 50 | $error = ''; |
| 56 | if($form->validate()){ | 51 | if($form->validate()){ |
| 57 | // destinataire = e-mail par défaut dans config.ini OU choisi par l'utilisateur | 52 | // destinataire = e-mail par défaut dans config.ini OU choisi par l'utilisateur |
| 58 | $form_data = $entityManager->find('App\Entity\NodeData', $json['id']); | 53 | $form_data = $entityManager->find(EmailForm::class, $json['id']); |
| 59 | if($form_data === null){ | 54 | if($form_data === null){ |
| 60 | return new JsonResponse(['success' => false, 'error' => 'server_error'], JsonResponse::HTTP_INTERNAL_SERVER_ERROR); // code 500 | 55 | return new JsonResponse(['success' => false, 'error' => 'server_error'], JsonResponse::HTTP_INTERNAL_SERVER_ERROR); // code 500 |
| 61 | } | 56 | } |
| @@ -78,7 +73,7 @@ class ContactFormController | |||
| 78 | static public function sendTestEmail(EntityManager $entityManager, array $json): JsonResponse | 73 | static public function sendTestEmail(EntityManager $entityManager, array $json): JsonResponse |
| 79 | { | 74 | { |
| 80 | // destinataire = e-mail par défaut dans config.ini OU choisi par l'utilisateur | 75 | // destinataire = e-mail par défaut dans config.ini OU choisi par l'utilisateur |
| 81 | $form_data = $entityManager->find('App\Entity\NodeData', $json['id']); | 76 | $form_data = $entityManager->find(EmailForm::class, $json['id']); |
| 82 | if($form_data === null){ | 77 | if($form_data === null){ |
| 83 | return new JsonResponse(['success' => false, 'error' => 'server_error'], JsonResponse::HTTP_INTERNAL_SERVER_ERROR); | 78 | return new JsonResponse(['success' => false, 'error' => 'server_error'], JsonResponse::HTTP_INTERNAL_SERVER_ERROR); |
| 84 | } | 79 | } |
| @@ -92,14 +87,14 @@ class ContactFormController | |||
| 92 | } | 87 | } |
| 93 | static public function deleteEmail(EntityManager $entityManager, array $json): JsonResponse | 88 | static public function deleteEmail(EntityManager $entityManager, array $json): JsonResponse |
| 94 | { | 89 | { |
| 95 | $email = $entityManager->find('App\Entity\Email', $json['id']); | 90 | $email = $entityManager->find(Email::class, $json['id']); |
| 96 | $entityManager->remove($email); | 91 | $entityManager->remove($email); |
| 97 | $entityManager->flush(); | 92 | $entityManager->flush(); |
| 98 | return new JsonResponse(['success' => true]); | 93 | return new JsonResponse(['success' => true]); |
| 99 | } | 94 | } |
| 100 | static public function toggleSensitiveEmail(EntityManager $entityManager, array $json): JsonResponse | 95 | static public function toggleSensitiveEmail(EntityManager $entityManager, array $json): JsonResponse |
| 101 | { | 96 | { |
| 102 | $email = $entityManager->find('App\Entity\Email', $json['id']); | 97 | $email = $entityManager->find(Email::class, $json['id']); |
| 103 | $email->makeSensitive($json['checked']); | 98 | $email->makeSensitive($json['checked']); |
| 104 | $entityManager->flush(); | 99 | $entityManager->flush(); |
| 105 | return new JsonResponse(['success' => true, 'checked' => $json['checked'], 'deletion_date' => $email->getDeletionDate()->format('d/m/Y')]); | 100 | return new JsonResponse(['success' => true, 'checked' => $json['checked'], 'deletion_date' => $email->getDeletionDate()->format('d/m/Y')]); |
diff --git a/src/controller/PageManagementController.php b/src/controller/PageManagementController.php index a43f36c..c575077 100644 --- a/src/controller/PageManagementController.php +++ b/src/controller/PageManagementController.php | |||
| @@ -6,6 +6,7 @@ declare(strict_types=1); | |||
| 6 | use App\Entity\Page; | 6 | use App\Entity\Page; |
| 7 | use App\Entity\Node; | 7 | use App\Entity\Node; |
| 8 | use App\Entity\NodeData; | 8 | use App\Entity\NodeData; |
| 9 | use App\Entity\EmailForm; | ||
| 9 | //use App\Entity\Image; | 10 | //use App\Entity\Image; |
| 10 | use Doctrine\ORM\EntityManager; | 11 | use Doctrine\ORM\EntityManager; |
| 11 | use Symfony\Component\HttpFoundation\InputBag; | 12 | use Symfony\Component\HttpFoundation\InputBag; |
| @@ -144,7 +145,9 @@ class PageManagementController | |||
| 144 | } | 145 | } |
| 145 | 146 | ||
| 146 | $block = new Node($request->request->get("bloc_select"), $position, $main, $page); | 147 | $block = new Node($request->request->get("bloc_select"), $position, $main, $page); |
| 147 | $data = new NodeData(['title' => trim(htmlspecialchars($request->request->get("bloc_title")))], $block); | 148 | |
| 149 | $DataClass = $request->request->get("bloc_select") === 'form' ? EmailForm::class : NodeData::class; // cas particulier avec bloc 'email_form' | ||
| 150 | $data = new $DataClass(['title' => trim(htmlspecialchars($request->request->get("bloc_title")))], $block); | ||
| 148 | 151 | ||
| 149 | // valeurs par défaut | 152 | // valeurs par défaut |
| 150 | if($request->request->get("bloc_select") === 'post_block'){ | 153 | if($request->request->get("bloc_select") === 'post_block'){ |
| @@ -200,8 +203,15 @@ class PageManagementController | |||
| 200 | if(isset($page)){ | 203 | if(isset($page)){ |
| 201 | $entityManager->persist($page); | 204 | $entityManager->persist($page); |
| 202 | } | 205 | } |
| 206 | $block->getNodeData()->setNode(null); | ||
| 203 | $entityManager->remove($block); | 207 | $entityManager->remove($block); |
| 204 | $entityManager->flush(); | 208 | try{ |
| 209 | $entityManager->flush(); | ||
| 210 | } | ||
| 211 | catch(Exception $e){ | ||
| 212 | // utiliser une flash error | ||
| 213 | return new RedirectResponse((string)new URL(['page' => $request->query->get('page'), 'mode' => 'page_modif', 'error' => $e->getMessage()])); | ||
| 214 | } | ||
| 205 | } | 215 | } |
| 206 | 216 | ||
| 207 | return new RedirectResponse((string)new URL(['page' => $request->query->get('page'), 'mode' => 'page_modif'])); | 217 | return new RedirectResponse((string)new URL(['page' => $request->query->get('page'), 'mode' => 'page_modif'])); |
| @@ -277,8 +287,7 @@ class PageManagementController | |||
| 277 | $chrono_order = false; | 287 | $chrono_order = false; |
| 278 | } | 288 | } |
| 279 | else{ | 289 | else{ |
| 280 | echo json_encode(['success' => false]); | 290 | return new JsonResponse(['success' => false]); |
| 281 | die; | ||
| 282 | } | 291 | } |
| 283 | $model->getNode()->getNodeData()->setChronoOrder($chrono_order); | 292 | $model->getNode()->getNodeData()->setChronoOrder($chrono_order); |
| 284 | $entityManager->flush(); | 293 | $entityManager->flush(); |
diff --git a/src/controller/UserController.php b/src/controller/UserController.php index ddba33a..03686ee 100644 --- a/src/controller/UserController.php +++ b/src/controller/UserController.php | |||
| @@ -122,7 +122,7 @@ class UserController | |||
| 122 | $url = new URL; | 122 | $url = new URL; |
| 123 | isset($_GET['from']) ? $url->addParams(['page' => $_GET['from']]) : ''; | 123 | isset($_GET['from']) ? $url->addParams(['page' => $_GET['from']]) : ''; |
| 124 | isset($_GET['id']) ? $url->addParams(['id' => $_GET['id']]) : ''; | 124 | isset($_GET['id']) ? $url->addParams(['id' => $_GET['id']]) : ''; |
| 125 | return new RedirectResponse('Location: ' . $url); | 125 | return new RedirectResponse((string)$url); |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | // user | 128 | // user |
| @@ -161,7 +161,7 @@ class UserController | |||
| 161 | sleep(1); | 161 | sleep(1); |
| 162 | $url->addParams(['error_username' => $error]); | 162 | $url->addParams(['error_username' => $error]); |
| 163 | } | 163 | } |
| 164 | return new RedirectResponse('Location: ' . $url); | 164 | return new RedirectResponse((string)$url); |
| 165 | } | 165 | } |
| 166 | 166 | ||
| 167 | // user | 167 | // user |
| @@ -200,7 +200,7 @@ class UserController | |||
| 200 | sleep(1); | 200 | sleep(1); |
| 201 | $url->addParams(['error_password' => $error]); | 201 | $url->addParams(['error_password' => $error]); |
| 202 | } | 202 | } |
| 203 | return new RedirectResponse('Location: ' . $url); | 203 | return new RedirectResponse((string)$url); |
| 204 | } | 204 | } |
| 205 | 205 | ||
| 206 | // dans une classe mère ou un trait après découpage de UserController? | 206 | // dans une classe mère ou un trait après découpage de UserController? |
diff --git a/src/model/entities/Email.php b/src/model/entities/Email.php index ff76653..60fcc1f 100644 --- a/src/model/entities/Email.php +++ b/src/model/entities/Email.php | |||
| @@ -48,18 +48,18 @@ class Email | |||
| 48 | #[ORM\Column(type: 'datetime', nullable: true)] | 48 | #[ORM\Column(type: 'datetime', nullable: true)] |
| 49 | private ?\DateTime $is_sensitive_since; | 49 | private ?\DateTime $is_sensitive_since; |
| 50 | 50 | ||
| 51 | #[ORM\ManyToOne(targetEntity: NodeData::class)] | 51 | #[ORM\ManyToOne(targetEntity: EmailForm::class)] |
| 52 | #[ORM\JoinColumn(name: "node_data_id", referencedColumnName: "id_node_data", nullable: true)] | 52 | #[ORM\JoinColumn(name: "email_form_id", referencedColumnName: "id_email_form", nullable: true)] |
| 53 | private ?NodeData $node_data; | 53 | private ?EmailForm $email_form; |
| 54 | 54 | ||
| 55 | public function __construct(string $sender_name, string $sender_address, string $recipient, string $content, NodeData $node_data, bool $sensitive = false){ | 55 | public function __construct(string $sender_name, string $sender_address, string $recipient, string $content, EmailForm $email_form, bool $sensitive = false){ |
| 56 | $this->sender_name = strtolower($sender_name); | 56 | $this->sender_name = strtolower($sender_name); |
| 57 | $this->sender_address = strtolower($sender_address); | 57 | $this->sender_address = strtolower($sender_address); |
| 58 | $this->recipient = strtolower($recipient); | 58 | $this->recipient = strtolower($recipient); |
| 59 | $this->content = $content; | 59 | $this->content = $content; |
| 60 | $this->date_time = new \DateTime; | 60 | $this->date_time = new \DateTime; |
| 61 | $this->last_contact_date = new \DateTime; | 61 | $this->last_contact_date = new \DateTime; |
| 62 | $this->node_data = $node_data; | 62 | $this->email_form = $email_form; |
| 63 | $this->makeSensitive($sensitive); | 63 | $this->makeSensitive($sensitive); |
| 64 | } | 64 | } |
| 65 | 65 | ||
| @@ -113,14 +113,14 @@ class Email | |||
| 113 | $this->last_contact_date = new \DateTime; | 113 | $this->last_contact_date = new \DateTime; |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | public function getDeletionDate(): \DateTime // utilise une durée de conservation $period qui est propre au bloc formulaire (à son NodeData) | 116 | public function getDeletionDate(): \DateTime // utilise une durée de conservation $period qui est propre au bloc formulaire (à son EmailForm) |
| 117 | { | 117 | { |
| 118 | // tests appliqués: | 118 | // tests appliqués: |
| 119 | // => e-mail associé à un formulaire? | 119 | // => e-mail associé à un formulaire? |
| 120 | // => ce formulaire dispose d'une durée de stockage spécifique? | 120 | // => ce formulaire dispose d'une durée de stockage spécifique? |
| 121 | // => cette donnée est un entier > 0 | 121 | // => cette donnée est un entier > 0 |
| 122 | $key = $this->is_sensitive ? 'retention_period_sensible' : 'retention_period'; | 122 | $key = $this->is_sensitive ? 'retention_period_sensible' : 'retention_period'; |
| 123 | $period = $this->node_data ? (int)($this->node_data->getData()[$key] ?? null) : null; | 123 | $period = $this->email_form ? (int)($this->email_form->getData()[$key] ?? null) : null; |
| 124 | 124 | ||
| 125 | $default = $this->is_sensitive ? self::DEFAULT_RETENTION_PERIOD_SENSITIVE : self::DEFAULT_RETENTION_PERIOD; | 125 | $default = $this->is_sensitive ? self::DEFAULT_RETENTION_PERIOD_SENSITIVE : self::DEFAULT_RETENTION_PERIOD; |
| 126 | $period = ($period === null || $period <= 0) ? $default : $period; | 126 | $period = ($period === null || $period <= 0) ? $default : $period; |
diff --git a/src/model/entities/EmailForm.php b/src/model/entities/EmailForm.php new file mode 100644 index 0000000..466a389 --- /dev/null +++ b/src/model/entities/EmailForm.php | |||
| @@ -0,0 +1,58 @@ | |||
| 1 | <?php | ||
| 2 | // src/model/entities/EmailForm.php | ||
| 3 | |||
| 4 | declare(strict_types=1); | ||
| 5 | |||
| 6 | namespace App\Entity; | ||
| 7 | |||
| 8 | use Doctrine\ORM\Mapping as ORM; | ||
| 9 | //use Doctrine\Common\Collections\ArrayCollection; | ||
| 10 | |||
| 11 | #[ORM\Entity] | ||
| 12 | #[ORM\Table(name: TABLE_PREFIX . "email_form")] | ||
| 13 | class EmailForm{ | ||
| 14 | #[ORM\Id] | ||
| 15 | #[ORM\GeneratedValue] | ||
| 16 | #[ORM\Column(type: "integer")] | ||
| 17 | private int $id_email_form; | ||
| 18 | |||
| 19 | // inverseBy fait le lien avec $email_form dans Node (qui a "mappedBy") | ||
| 20 | #[ORM\OneToOne(targetEntity: Node::class, inversedBy: "email_form")] | ||
| 21 | #[ORM\JoinColumn(name: "node_id", referencedColumnName: "id_node")] | ||
| 22 | private ?Node $node; | ||
| 23 | |||
| 24 | #[ORM\Column(type: "json")] | ||
| 25 | private array $data; | ||
| 26 | |||
| 27 | public function __construct(array $data, Node $node){ | ||
| 28 | $this->data = $data; | ||
| 29 | $this->node = $node; | ||
| 30 | } | ||
| 31 | |||
| 32 | public function getId(): int | ||
| 33 | { | ||
| 34 | return $this->id_email_form; | ||
| 35 | } | ||
| 36 | |||
| 37 | // getData et updateData sont indentiques au code dans NodeData | ||
| 38 | // plutôt qu'une interface, pourquoi pas une classe abstraite? ou peut-être un trait? | ||
| 39 | public function getData(): array | ||
| 40 | { | ||
| 41 | return $this->data; | ||
| 42 | } | ||
| 43 | public function updateData(string $key, string|int|bool|array $value = ''): void | ||
| 44 | { | ||
| 45 | if($value !== ''){ | ||
| 46 | $this->data[$key] = $value; | ||
| 47 | } | ||
| 48 | // si $value est vide, supprime la clé | ||
| 49 | elseif(isset($this->data[$key])){ | ||
| 50 | unset($this->data[$key]); | ||
| 51 | } | ||
| 52 | } | ||
| 53 | |||
| 54 | public function setNode(?Node $node): void | ||
| 55 | { | ||
| 56 | $this->node = $node; | ||
| 57 | } | ||
| 58 | } \ No newline at end of file | ||
diff --git a/src/model/entities/Node.php b/src/model/entities/Node.php index 71c159d..c3e4ec3 100644 --- a/src/model/entities/Node.php +++ b/src/model/entities/Node.php | |||
| @@ -45,13 +45,14 @@ class Node | |||
| 45 | #[ORM\OneToOne(targetEntity: NodeData::class, mappedBy: "node", cascade: ['persist', 'remove'])] | 45 | #[ORM\OneToOne(targetEntity: NodeData::class, mappedBy: "node", cascade: ['persist', 'remove'])] |
| 46 | private ?NodeData $node_data = null; | 46 | private ?NodeData $node_data = null; |
| 47 | 47 | ||
| 48 | #[ORM\OneToOne(targetEntity: EmailForm::class, mappedBy: "node", cascade: ['persist'])] // pas de remove, les e-mails sont associés au EmailForm | ||
| 49 | private ?EmailForm $email_form = null; | ||
| 48 | 50 | ||
| 49 | // attributs non destinés à doctrine | 51 | // attributs non destinés à doctrine |
| 50 | private array $children = []; // tableau de Node | 52 | private array $children = []; // tableau de Node |
| 51 | private ?self $adopted = null; // = "new" est un enfant de "main" lorsque la page est "article" | 53 | private ?self $adopted = null; // = "new" est un enfant de "main" lorsque la page est "article" |
| 52 | 54 | ||
| 53 | public function __construct(string $name = '', int $position = 0, ?self $parent = null, ?Page $page = null, ?Article $article = null) | 55 | public function __construct(string $name = '', int $position = 0, ?self $parent = null, ?Page $page = null, ?Article $article = null){ |
| 54 | { | ||
| 55 | $this->name_node = $name; | 56 | $this->name_node = $name; |
| 56 | $this->position = $position; | 57 | $this->position = $position; |
| 57 | $this->parent = $parent; | 58 | $this->parent = $parent; |
| @@ -105,9 +106,10 @@ class Node | |||
| 105 | { | 106 | { |
| 106 | $this->article = $article; | 107 | $this->article = $article; |
| 107 | }*/ | 108 | }*/ |
| 108 | public function getNodeData(): ?NodeData | 109 | // une interface serait cool! |
| 110 | public function getNodeData(): NodeData|EmailForm|null | ||
| 109 | { | 111 | { |
| 110 | return $this->node_data; | 112 | return $this->name_node === 'form' ? $this->email_form : $this->node_data; |
| 111 | } | 113 | } |
| 112 | public function getChildren(): array | 114 | public function getChildren(): array |
| 113 | { | 115 | { |
diff --git a/src/model/entities/NodeData.php b/src/model/entities/NodeData.php index 49bfb3c..c55f6a1 100644 --- a/src/model/entities/NodeData.php +++ b/src/model/entities/NodeData.php | |||
| @@ -44,9 +44,6 @@ class NodeData | |||
| 44 | #[ORM\OneToMany(mappedBy: 'node_data', targetEntity: AssetEmployment::class, cascade: ['persist', 'remove'])] | 44 | #[ORM\OneToMany(mappedBy: 'node_data', targetEntity: AssetEmployment::class, cascade: ['persist', 'remove'])] |
| 45 | private Collection $asset_employment; | 45 | private Collection $asset_employment; |
| 46 | 46 | ||
| 47 | /*#[ORM\OneToMany(mappedBy: 'node_data', targetEntity: Email::class, cascade: ['persist', 'remove'])] // => noeud "form", inutilisé et conflit avec le tableau $emails | ||
| 48 | private Collection $emails;*/ | ||
| 49 | |||
| 50 | private int $nb_pages = 1; | 47 | private int $nb_pages = 1; |
| 51 | private array $emails = []; // => noeud "show_emails" | 48 | private array $emails = []; // => noeud "show_emails" |
| 52 | 49 | ||
| @@ -157,6 +154,7 @@ class NodeData | |||
| 157 | return $nda->getAsset() ?? null; | 154 | return $nda->getAsset() ?? null; |
| 158 | } | 155 | } |
| 159 | 156 | ||
| 157 | // pour affichage page Courriels | ||
| 160 | public function getEmails(): array // appelée dans ShowEmailsBuilder | 158 | public function getEmails(): array // appelée dans ShowEmailsBuilder |
| 161 | { | 159 | { |
| 162 | return $this->emails; | 160 | return $this->emails; |
diff --git a/src/service/EmailService.php b/src/service/EmailService.php index 0ea8f39..1579bdb 100644 --- a/src/service/EmailService.php +++ b/src/service/EmailService.php | |||
| @@ -7,13 +7,13 @@ use PHPMailer\PHPMailer\PHPMailer; | |||
| 7 | //use PHPMailer\PHPMailer\Exception; | 7 | //use PHPMailer\PHPMailer\Exception; |
| 8 | use Doctrine\ORM\EntityManager; | 8 | use Doctrine\ORM\EntityManager; |
| 9 | use App\Entity\Email; | 9 | use App\Entity\Email; |
| 10 | use App\Entity\NodeData; | 10 | use App\Entity\EmailForm; |
| 11 | 11 | ||
| 12 | class EmailService | 12 | class EmailService |
| 13 | { | 13 | { |
| 14 | const KEEP_EMAILS_DEFAULT = false; | 14 | const KEEP_EMAILS_DEFAULT = false; |
| 15 | 15 | ||
| 16 | static public function send(EntityManager $entityManager, NodeData $form_data, bool $test_email, string $name = '', string $email = '', string $message = ''): bool | 16 | static public function send(EntityManager $entityManager, EmailForm $form_data, bool $test_email, string $name = '', string $email = '', string $message = ''): bool |
| 17 | { | 17 | { |
| 18 | $mail = new PHPMailer(true); // true => exceptions | 18 | $mail = new PHPMailer(true); // true => exceptions |
| 19 | $mail->CharSet = 'UTF-8'; | 19 | $mail->CharSet = 'UTF-8'; |
diff --git a/src/view/ShowEmailsBuilder.php b/src/view/ShowEmailsBuilder.php index 3d2d6a9..e88b349 100644 --- a/src/view/ShowEmailsBuilder.php +++ b/src/view/ShowEmailsBuilder.php | |||
| @@ -8,7 +8,7 @@ use App\Entity\Page; | |||
| 8 | 8 | ||
| 9 | class ShowEmailsBuilder extends AbstractBuilder | 9 | class ShowEmailsBuilder extends AbstractBuilder |
| 10 | { | 10 | { |
| 11 | public function __construct(Node $node = null) | 11 | public function __construct(?Node $node) |
| 12 | { | 12 | { |
| 13 | //parent::__construct($node); | 13 | //parent::__construct($node); |
| 14 | $viewFile = self::VIEWS_PATH . $node->getName() . '.php'; | 14 | $viewFile = self::VIEWS_PATH . $node->getName() . '.php'; |
