<?php
declare(strict_types=1);

namespace App\Controller;

use Cake\Event\EventInterface;
use Cake\Controller\Controller;

class AppController extends Controller
{
    public function initialize(): void
    {
        parent::initialize();

        $this->loadComponent('Flash');
        $this->loadComponent('FormProtection');
    }

    public function beforeRender(EventInterface $event): void
    {
        parent::beforeRender($event);

        $identity = $this->request->getAttribute('identity');
        $this->set('currentAdminName', $identity?->get('display_name'));
        $this->set('isAdminAuthenticated', $identity !== null);
    }
}
