diff options
Diffstat (limited to 'src/model')
-rw-r--r-- | src/model/entities/Log.php | 28 | ||||
-rw-r--r-- | src/model/entities/Node.php | 5 |
2 files changed, 31 insertions, 2 deletions
diff --git a/src/model/entities/Log.php b/src/model/entities/Log.php new file mode 100644 index 0000000..7c2caa9 --- /dev/null +++ b/src/model/entities/Log.php | |||
@@ -0,0 +1,28 @@ | |||
1 | <?php | ||
2 | // src/model/entities/Log.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 | use Doctrine\Common\Collections\Collection; | ||
11 | |||
12 | #[ORM\Entity] | ||
13 | #[ORM\Table(name: TABLE_PREFIX . "log")] | ||
14 | class Log | ||
15 | { | ||
16 | #[ORM\Id] | ||
17 | #[ORM\GeneratedValue] | ||
18 | #[ORM\Column(type: "integer")] | ||
19 | private int $id_log; | ||
20 | |||
21 | #[ORM\Column(type: 'datetime', options: ['default' => 'CURRENT_TIMESTAMP'])] | ||
22 | //#[ORM\Column(type: 'datetime', columnDefinition: "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")] | ||
23 | private ?\DateTime $date_time ; // le type datetime de doctrine convertit en type \DateTime de PHP | ||
24 | |||
25 | public function __construct(){ | ||
26 | $this->date_time = new \DateTime(); | ||
27 | } | ||
28 | } | ||
diff --git a/src/model/entities/Node.php b/src/model/entities/Node.php index fea9d50..850f37d 100644 --- a/src/model/entities/Node.php +++ b/src/model/entities/Node.php | |||
@@ -36,12 +36,13 @@ class Node | |||
36 | #[ORM\JoinColumn(name: "parent_id", referencedColumnName: "id_node", onDelete: "SET NULL", nullable: true)] | 36 | #[ORM\JoinColumn(name: "parent_id", referencedColumnName: "id_node", onDelete: "SET NULL", nullable: true)] |
37 | private ?self $parent = null; | 37 | private ?self $parent = null; |
38 | 38 | ||
39 | // un onDelete: "CASCADE" serait logique ici mais dangereux, on pourrait aussi faire en sorte que les noeuds soient récupérables si la page est brutalement supprimée | ||
39 | #[ORM\ManyToOne(targetEntity: Page::class)] | 40 | #[ORM\ManyToOne(targetEntity: Page::class)] |
40 | #[ORM\JoinColumn(name: "page_id", referencedColumnName: "id_page", onDelete: "SET DEFAULT", nullable: true)] | 41 | #[ORM\JoinColumn(name: "page_id", referencedColumnName: "id_page", nullable: true)] |
41 | private ?Page $page; | 42 | private ?Page $page; |
42 | 43 | ||
43 | #[ORM\ManyToOne(targetEntity: Article::class, cascade: ['persist'])] | 44 | #[ORM\ManyToOne(targetEntity: Article::class, cascade: ['persist'])] |
44 | #[ORM\JoinColumn(name: "article_id", referencedColumnName: "id_article", onDelete: "SET NULL", nullable: true)] | 45 | #[ORM\JoinColumn(name: "article_id", referencedColumnName: "id_article", onDelete: "CASCADE", nullable: true)] // supprimer le contenu d'un article supprime les noeuds associés, faux dans l'autre sens |
45 | private ?Article $article = null; | 46 | private ?Article $article = null; |
46 | 47 | ||
47 | // propriété non mappée dans la table "node", la jointure est décrite dans NodeData | 48 | // propriété non mappée dans la table "node", la jointure est décrite dans NodeData |