aboutsummaryrefslogtreecommitdiff
path: root/src/View/ViewDirector.php
blob: af351799058a0b805294e842a0b6a5785a47438d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
// src/View/ViewDirector.php
//
// génère le HTML avec des Builder

declare(strict_types=1);

namespace App\View;

use App\Entity\Node;

class ViewDirector extends AbstractBuilder // ViewDirector est le premier Builder
{
    public Node $root_node;

    public function __construct(){} // surcharge celui de AbstractBuilder

    public function buildHTML(Node $root_node): string
    {
        $this->root_node = $root_node;
        $this->useChildrenBuilder($this->root_node);

        if(isset($_SESSION['flash_message'])){
            $this->html .= '<script>window.flash_message = "' . $_SESSION['flash_message'] . '";</script>';
            unset($_SESSION['flash_message']);
        }

        return $this->html;
    }
}