hesabixSite/src/Controller/Admin/DashboardController.php
2025-01-10 21:59:38 +00:00

92 lines
3.7 KiB
PHP

<?php
namespace App\Controller\Admin;
use App\Entity\Post;
use App\Entity\Tree;
use App\Entity\User;
use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard;
use EasyCorp\Bundle\EasyAdminBundle\Config\Locale;
use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
class DashboardController extends AbstractDashboardController
{
#[Route('/admin/{_locale}', name: 'admin')]
public function index($_locale = 'fa'): 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('admin/dashboard.html.twig');
}
public function configureDashboard(): Dashboard
{
return Dashboard::new()
// you can include HTML contents too (e.g. to link to an image)
->setTitle('پیشخوان')
// 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/favicon.ico')
// the domain used by default is 'messages'
->setTranslationDomain('admin')
// 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()
// by default, the UI color scheme is 'auto', which means that the backend
// will use the same mode (light/dark) as the operating system and will
// change in sync when the OS mode changes.
// Use this option to set which mode ('light', 'dark' or 'auto') will users see
// by default in the backend (users can change it via the color scheme selector)
->setDefaultColorScheme('dark')
// instead of magic strings, you can use constants as the value of
// this option: EasyCorp\Bundle\EasyAdminBundle\Config\Option\ColorScheme::DARK
// by default, all backend URLs are generated as absolute URLs. If you
// need to generate relative URLs instead, call this method
->generateRelativeUrls()
->setLocales(['en','fa'])
// to further customize the locale option, pass an instance of
// EasyCorp\Bundle\EasyAdminBundle\Config\Locale
;
}
public function configureMenuItems(): iterable
{
return [
MenuItem::linkToDashboard('پیشخوان', 'fa fa-home'),
MenuItem::section('پست بلاگ'),
MenuItem::linkToCrud('دسته بندی', 'fa fa-tags', Tree::class),
MenuItem::linkToCrud('محتوا', 'fa fa-file-text', Post::class),
MenuItem::section('کاربران'),
MenuItem::linkToCrud('کاربران', 'fa fa-user', User::class),
];
}
}