hesabixSite/src/Controller/Admin/DashboardController.php

92 lines
3.7 KiB
PHP
Raw Normal View History

2025-01-10 21:33:20 +03:30
<?php
namespace App\Controller\Admin;
2025-01-11 01:29:38 +03:30
use App\Entity\Post;
use App\Entity\Tree;
use App\Entity\User;
2025-01-10 21:33:20 +03:30
use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard;
2025-01-11 01:29:38 +03:30
use EasyCorp\Bundle\EasyAdminBundle\Config\Locale;
2025-01-10 21:33:20 +03:30
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
{
2025-01-11 01:29:38 +03:30
#[Route('/admin/{_locale}', name: 'admin')]
public function index($_locale = 'fa'): Response
2025-01-10 21:33:20 +03:30
{
2025-01-11 01:29:38 +03:30
//return parent::index();
2025-01-10 21:33:20 +03:30
// 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)
//
2025-01-11 01:29:38 +03:30
return $this->render('admin/dashboard.html.twig');
2025-01-10 21:33:20 +03:30
}
public function configureDashboard(): Dashboard
{
return Dashboard::new()
2025-01-10 21:39:29 +03:30
// you can include HTML contents too (e.g. to link to an image)
2025-01-11 01:29:38 +03:30
->setTitle('پیشخوان')
2025-01-10 21:39:29 +03:30
// 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('...') }}">
2025-01-11 01:29:38 +03:30
->setFaviconPath('favicon/favicon.ico')
2025-01-10 21:39:29 +03:30
// the domain used by default is 'messages'
2025-01-11 01:29:38 +03:30
->setTranslationDomain('admin')
2025-01-10 21:39:29 +03:30
// 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()
2025-01-11 01:29:38 +03:30
->setLocales(['en','fa'])
// to further customize the locale option, pass an instance of
// EasyCorp\Bundle\EasyAdminBundle\Config\Locale
2025-01-10 21:39:29 +03:30
;
2025-01-10 21:33:20 +03:30
}
public function configureMenuItems(): iterable
{
2025-01-11 01:29:38 +03:30
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),
];
2025-01-10 21:33:20 +03:30
}
2025-01-11 01:29:38 +03:30
2025-01-10 21:33:20 +03:30
}