. */ namespace SP\Core; use SP\Providers\Acl\AclHandler; use SP\Providers\Log\DatabaseLogHandler; use SP\Providers\Log\FileLogHandler; use SP\Providers\Log\RemoteSyslogHandler; use SP\Providers\Log\SyslogHandler; use SP\Providers\Mail\MailHandler; use SP\Providers\Notification\NotificationHandler; use SP\Providers\ProviderInterface; /** * The Provider helper class will have oll the providers availabe in the application */ final readonly class ProvidersHelper { public function __construct( private FileLogHandler $fileLogHandler, private ?DatabaseLogHandler $databaseLogHandler = null, private ?MailHandler $mailHandler = null, private ?SyslogHandler $syslogHandler = null, private ?RemoteSyslogHandler $remoteSyslogHandler = null, private ?AclHandler $aclHandler = null, private ?NotificationHandler $notificationHandler = null ) { } public function getFileLogHandler(): FileLogHandler { self::ensureIsInitialized($this->fileLogHandler); return $this->fileLogHandler; } private static function ensureIsInitialized(?ProviderInterface $provider = null): void { if ($provider !== null && !$provider->isInitialized()) { $provider->initialize(); } } public function getDatabaseLogHandler(): DatabaseLogHandler { self::ensureIsInitialized($this->databaseLogHandler); return $this->databaseLogHandler; } public function getMailHandler(): MailHandler { self::ensureIsInitialized($this->mailHandler); return $this->mailHandler; } public function getSyslogHandler(): SyslogHandler { self::ensureIsInitialized($this->syslogHandler); return $this->syslogHandler; } public function getRemoteSyslogHandler(): RemoteSyslogHandler { self::ensureIsInitialized($this->remoteSyslogHandler); return $this->remoteSyslogHandler; } public function getAclHandler(): AclHandler { self::ensureIsInitialized($this->aclHandler); return $this->aclHandler; } public function getNotificationHandler(): NotificationHandler { self::ensureIsInitialized($this->notificationHandler); return $this->notificationHandler; } }