30 lines
528 B
PHP
30 lines
528 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
final class Flash
|
|
{
|
|
private const CLE = "_flash";
|
|
|
|
public static function definir(string $type, string $message): void
|
|
{
|
|
$_SESSION[self::CLE] = [
|
|
"type" => $type,
|
|
"message" => $message
|
|
];
|
|
}
|
|
|
|
public static function consommer(): ?array
|
|
{
|
|
if (empty($_SESSION[self::CLE]))
|
|
{
|
|
return null;
|
|
}
|
|
|
|
$flash = $_SESSION[self::CLE];
|
|
unset($_SESSION[self::CLE]);
|
|
|
|
return $flash;
|
|
}
|
|
}
|