35 lines
827 B
PHP
35 lines
827 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Presentation\Accessory;
|
|
|
|
use App\Model\LoginFacade;
|
|
use Nette\Application\Application;
|
|
use Nette\Application\UI\Presenter;
|
|
use Nette\Security\User;
|
|
|
|
/**
|
|
* Do šablony doplní, jestli má přihlášený účet oprávnění správce.
|
|
*/
|
|
final class AdminMenuService
|
|
{
|
|
public function __construct(
|
|
private User $user,
|
|
private LoginFacade $uzivatele,
|
|
) {
|
|
}
|
|
|
|
public function pripoj(Application $application, object $presenter): void
|
|
{
|
|
if (!$presenter instanceof Presenter) {
|
|
return;
|
|
}
|
|
|
|
$presenter->onRender[] = function () use ($presenter): void {
|
|
$presenter->template->jeAdmin = $this->user->isLoggedIn()
|
|
&& $this->uzivatele->jeAdmin((int) $this->user->getId());
|
|
};
|
|
}
|
|
}
|