diff options
Diffstat (limited to 'src/model/entities/Node.php')
| -rw-r--r-- | src/model/entities/Node.php | 10 |
1 files changed, 6 insertions, 4 deletions
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 | { |
