<?php
namespace App\Controller\Admin;
use App\Entity\Adressen;
use App\Entity\City;
use App\Entity\DeliveryRequest;
use App\Entity\Driver;
use App\Entity\KeyToAccess;
use App\Entity\OrderGermany;
use App\Entity\OrderUkraine;
use App\Entity\Routers;
use App\Entity\User;
use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard;
use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Security;
class DashboardController extends AbstractDashboardController
{
private $security;
public function __construct(Security $security)
{
$this->security = $security;
}
#[Route('/admin', name: 'admin')]
public function index(): Response
{
//return parent::index();
// Option 1. You can make your dashboard redirect to some common page of your backend
//
// $adminUrlGenerator = $this->container->get(AdminUrlGenerator::class);
// return $this->redirect($adminUrlGenerator->setController(OneOfYourCrudController::class)->generateUrl());
// Option 2. You can make your dashboard redirect to different pages depending on the user
//
// if ('jane' === $this->getUser()->getUsername()) {
// return $this->redirect('...');
// }
// Option 3. You can render some custom template to display a proper dashboard with widgets, etc.
// (tip: it's easier if your template extends from @EasyAdmin/page/content.html.twig)
//
// return $this->render('some/path/my-dashboard.html.twig');
return $this->render('admin/my-dashboard.html.twig');
}
public function configureDashboard(): Dashboard
{
return Dashboard::new()
// the name visible to end users
->setTitle('Доставка')
// you can include HTML contents too (e.g. to link to an image)
->setTitle('<img src="..."> Доставка <span class="text-small">Админка.</span>')
// by default EasyAdmin displays a black square as its default favicon;
// use this method to display a custom favicon: the given path is passed
// "as is" to the Twig asset() function:
// <link rel="shortcut icon" href="{{ asset('...') }}">
->setFaviconPath('favicon.svg')
// the domain used by default is 'messages'
->setTranslationDomain('my-custom-domain')
// there's no need to define the "text direction" explicitly because
// its default value is inferred dynamically from the user locale
->setTextDirection('ltr')
// set this option if you prefer the page content to span the entire
// browser width, instead of the default design which sets a max width
->renderContentMaximized()
// set this option if you prefer the sidebar (which contains the main menu)
// to be displayed as a narrow column instead of the default expanded design
->renderSidebarMinimized()
// by default, users can select between a "light" and "dark" mode for the
// backend interface. Call this method if you prefer to disable the "dark"
// mode for any reason (e.g. if your interface customizations are not ready for it)
->disableDarkMode()
// by default, all backend URLs are generated as absolute URLs. If you
// need to generate relative URLs instead, call this method
->generateRelativeUrls()
// set this option if you want to enable locale switching in dashboard.
// IMPORTANT: this feature won't work unless you add the {_locale}
// parameter in the admin dashboard URL (e.g. '/admin/{_locale}').
// the name of each locale will be rendered in that locale
// (in the following example you'll see: "English", "Polski")
->setLocales(['en', 'pl'])
// to customize the labels of locales, pass a key => value array
// (e.g. to display flags; although it's not a recommended practice,
// because many languages/locales are not associated to a single country)
->setLocales([
'en' => '🇬🇧 English',
'pl' => '🇵🇱 Polski'
])
// to further customize the locale option, pass an instance of
// EasyCorp\Bundle\EasyAdminBundle\Config\Locale
->setLocales([
'en', // locale without custom options
])
;
}
public function configureMenuItems(): iterable
{
yield MenuItem::linkToDashboard('Головна', 'fa fa-home');
// yield MenuItem::linkToCrud('Посики з Украины', 'fa fa-home', OrderUkraine::class);
if ($this->security->isGranted('ROLE_ADMIN_UKRAINE')) {
yield MenuItem::linkToRoute('Скан', 'fa fa-home', "admin_scan");
yield MenuItem::linkToRoute('Пошук', 'fa fa-home', "admin_search");
yield MenuItem::linkToCrud('Актуальні', 'fa fa-home', OrderUkraine::class)
->setController(OrderUkraineCrudController::class);
yield MenuItem::linkToCrud('В Німеччині', 'fa fa-home', OrderUkraine::class)
->setController(OrderUkraineCrudDeliveredController::class);
}
if ($this->security->isGranted('ROLE_SUPER_ADMIN')) {
yield MenuItem::section('Посилки з україни');
yield MenuItem::linkToCrud('Актуальні', 'fa fa-home', OrderUkraine::class)
->setController(OrderUkraineCrudController::class);
yield MenuItem::linkToCrud('В Німеччині', 'fa fa-home', OrderUkraine::class)
->setController(OrderUkraineCrudDeliveredController::class);
yield MenuItem::linkToCrud('Відгружені (Архів)', 'fa fa-home', OrderUkraine::class)
->setController(OrderUkraineOldCrudController::class);
yield MenuItem::linkToCrud('На складі (Архів)', 'fa fa-home', OrderUkraine::class)
->setController(OrderUkraineSkladCrudController::class);
yield MenuItem::linkToCrud('Замовлення доставки', 'fa fa-home', DeliveryRequest::class);
yield MenuItem::linkToCrud('Міста', 'fa fa-home', City::class);
yield MenuItem::linkToCrud('Ключі', 'fa fa-home', KeyToAccess::class);
yield MenuItem::linkToCrud('Водії', 'fa fa-home', Driver::class);
yield MenuItem::linkToCrud('Адреса видачі', 'fa fa-home', Adressen::class);
yield MenuItem::linkToCrud('Маршрути', 'fa fa-home', Routers::class);
yield MenuItem::linkToCrud('Користувачі', 'fa fa-home', User::class);
yield MenuItem::linkToRoute('Роздрукувати у німетчині адмін ', 'fa fa-print', 'pdf_generate2')
->setLinkTarget('_blank');
yield MenuItem::linkToRoute('Роздрукувати у німетчині', 'fa fa-print', 'pdf_generate_driver')
->setLinkTarget('_blank');
yield MenuItem::linkToRoute('Роздрукувати актуальні', 'fa fa-print', 'pdf_ggenerateAktual')
->setLinkTarget('_blank');
yield MenuItem::linkToRoute('Роздрукувати склад', 'fa fa-print', 'pdf_generateSklad')
->setLinkTarget('_blank');
// Добавьте другие элементы меню для ROLE_SUPER_ADMIN, если нужно
}
/* yield MenuItem::linkToCrud('Посики з України', 'fa fa-home');
yield MenuItem::linkToCrud('Користувачі', 'fa fa-home');*/
// yield MenuItem::linkToCrud('The Label', 'fas fa-list', EntityClass::class);
}
}