diff options
| author | polo-pc-greta <ordipolo@gmx.fr> | 2025-03-27 10:13:03 +0100 |
|---|---|---|
| committer | polo-pc-greta <ordipolo@gmx.fr> | 2025-03-27 10:13:03 +0100 |
| commit | df3612ed7e6691530503f79483d2fdbc032d01b8 (patch) | |
| tree | 56d1c68fdc8625f5dad1937a654299d45142c79a /src/model/entities/Page.php | |
| download | cms-df3612ed7e6691530503f79483d2fdbc032d01b8.tar.gz cms-df3612ed7e6691530503f79483d2fdbc032d01b8.tar.bz2 cms-df3612ed7e6691530503f79483d2fdbc032d01b8.zip | |
mise en ligne github
Diffstat (limited to 'src/model/entities/Page.php')
| -rw-r--r-- | src/model/entities/Page.php | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/src/model/entities/Page.php b/src/model/entities/Page.php new file mode 100644 index 0000000..d7d8098 --- /dev/null +++ b/src/model/entities/Page.php | |||
| @@ -0,0 +1,97 @@ | |||
| 1 | <?php | ||
| 2 | // src/model/entities/Page.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\Collection; | ||
| 10 | use Doctrine\Common\Collections\ArrayCollection; | ||
| 11 | |||
| 12 | #[ORM\Entity] | ||
| 13 | #[ORM\Table(name: TABLE_PREFIX . "page")] | ||
| 14 | class Page | ||
| 15 | { | ||
| 16 | #[ORM\Id] | ||
| 17 | #[ORM\GeneratedValue] | ||
| 18 | #[ORM\Column(type: "integer")] | ||
| 19 | private int $id_page; | ||
| 20 | |||
| 21 | #[ORM\Column(type: "string", length: 255)] | ||
| 22 | private string $name_page; | ||
| 23 | |||
| 24 | #[ORM\Column(type: "string", length: 255)] | ||
| 25 | private string $end_of_path; // morceau d'URL plus exactement | ||
| 26 | |||
| 27 | private string $page_path; | ||
| 28 | |||
| 29 | #[ORM\Column(type: "boolean")] | ||
| 30 | private bool $reachable; | ||
| 31 | |||
| 32 | #[ORM\Column(type: "boolean")] | ||
| 33 | private bool $in_menu; | ||
| 34 | |||
| 35 | #[ORM\ManyToOne(targetEntity: self::class)] | ||
| 36 | #[ORM\JoinColumn(name: "parent_id", referencedColumnName: "id_page", onDelete: "SET NULL", nullable: true)] | ||
| 37 | private ?self $parent = null; | ||
| 38 | |||
| 39 | #[ORM\OneToMany(targetEntity: self::class, mappedBy: 'parent')] | ||
| 40 | protected Collection $children; | ||
| 41 | |||
| 42 | /*#[ORM\Column(type: "json", nullable: true)] | ||
| 43 | private ?array $metadata = null;*/ | ||
| 44 | |||
| 45 | public function __construct(string $name, string $eop, bool $reachable, bool $in_menu, ?Page $parent) | ||
| 46 | { | ||
| 47 | $this->name_page = $name; | ||
| 48 | $this->end_of_path = $eop; | ||
| 49 | $this->reachable = $reachable; | ||
| 50 | $this->in_menu = $in_menu; | ||
| 51 | $this->parent = $parent; | ||
| 52 | $this->children = new ArrayCollection(); | ||
| 53 | } | ||
| 54 | |||
| 55 | // getters | ||
| 56 | /*public function getId(): int | ||
| 57 | { | ||
| 58 | return $this->id_page; | ||
| 59 | }*/ | ||
| 60 | public function getPageName(): string | ||
| 61 | { | ||
| 62 | return $this->name_page; | ||
| 63 | } | ||
| 64 | public function getPagePath(): string | ||
| 65 | { | ||
| 66 | return $this->page_path; | ||
| 67 | } | ||
| 68 | public function getEndOfPath(): string | ||
| 69 | { | ||
| 70 | return $this->end_of_path; | ||
| 71 | } | ||
| 72 | public function getInMenu(): bool | ||
| 73 | { | ||
| 74 | return $this->in_menu; | ||
| 75 | } | ||
| 76 | public function getParent(): ?Page | ||
| 77 | { | ||
| 78 | return $this->parent; | ||
| 79 | } | ||
| 80 | public function getChildren(): Collection | ||
| 81 | { | ||
| 82 | return $this->children; | ||
| 83 | } | ||
| 84 | |||
| 85 | public function fillChildrenPagePath(string $parent_path = ''): void | ||
| 86 | { | ||
| 87 | $this->page_path = $parent_path != '' ? $parent_path . '/' . $this->end_of_path : $this->end_of_path; | ||
| 88 | foreach($this->getChildren() as $page){ | ||
| 89 | $page->fillChildrenPagePath($this->page_path); | ||
| 90 | } | ||
| 91 | } | ||
| 92 | |||
| 93 | public function addChild(self $child): void | ||
| 94 | { | ||
| 95 | $this->children[] = $child; | ||
| 96 | } | ||
| 97 | } | ||
