presseportale/app/Services/CurrentPortalContext.php
Kevin Adametz 5b8bdf4182
Some checks are pending
linter / quality (push) Waiting to run
tests / ci (push) Waiting to run
12-05-2026 Frontend dev
2026-05-12 18:32:33 +02:00

36 lines
729 B
PHP

<?php
namespace App\Services;
use App\Enums\Portal;
/**
* Hält den aktiven Portal-Kontext für den aktuellen Request.
*
* Wird vom SetCurrentPortal-Middleware gesetzt und von PortalScope gelesen.
* In CLI-Befehlen und Queue-Jobs bleibt der Kontext null → kein Filter.
*/
class CurrentPortalContext
{
private static ?Portal $portal = null;
public static function set(?Portal $portal): void
{
static::$portal = $portal;
}
public static function get(): ?Portal
{
return static::$portal;
}
public static function isActive(): bool
{
return static::$portal !== null;
}
public static function clear(): void
{
static::$portal = null;
}
}