<?php

namespace AutoAdmin\Bundle\Admin\Twig\Extension;

use Twig\Environment;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;

class FrontendBarExtension extends AbstractExtension
{
    private Environment $twig;

    public function __construct(Environment $twig)
    {
        $this->twig = $twig;
    }

    public function getFunctions(): array
    {
        return [
            new TwigFunction('aa_admin_bar', [$this, 'getBar'], ['is_safe' => ['html'],]),
        ];
    }

    public function getBar(): string
    {
        return $this->twig->render('@AutoAdminAdmin/administrator/admin_bar.html.twig', []);
    }
}
