added avatar
This commit is contained in:
parent
b562f3cae8
commit
2dfe0070e2
|
@ -5,12 +5,18 @@ namespace App\Controller\Admin;
|
||||||
use App\Entity\Projects;
|
use App\Entity\Projects;
|
||||||
use App\Entity\Quotes;
|
use App\Entity\Quotes;
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
|
use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
|
||||||
|
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
|
||||||
|
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
|
||||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard;
|
use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard;
|
||||||
use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem;
|
use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem;
|
||||||
|
use EasyCorp\Bundle\EasyAdminBundle\Config\UserMenu;
|
||||||
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController;
|
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController;
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
|
||||||
|
use Symfony\Component\Config\Definition\Exception\Exception;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
use Symfony\Component\Security\Core\User\UserInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -18,24 +24,44 @@ use Symfony\Component\Routing\Annotation\Route;
|
||||||
class DashboardController extends AbstractDashboardController
|
class DashboardController extends AbstractDashboardController
|
||||||
{
|
{
|
||||||
#[isGranted(data: 'ROLE_ADMIN')]
|
#[isGranted(data: 'ROLE_ADMIN')]
|
||||||
#[Route(path: '/admin', name: 'admin')]
|
#[Route(path: '/admin', name: 'admin')]
|
||||||
public function index(): Response
|
public function index(): Response
|
||||||
{
|
{
|
||||||
//return parent::index();
|
//return parent::index();
|
||||||
return $this->render(view: 'admin/index.html.twig');
|
return $this->render(view: 'admin/index.html.twig');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function configureDashboard(): Dashboard
|
||||||
|
{
|
||||||
|
return Dashboard::new()
|
||||||
|
->setTitle(title: '24unix Admin');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configureMenuItems(): iterable
|
||||||
|
{
|
||||||
|
yield MenuItem::linkToUrl(label: 'Homepage', icon: 'fa fa-home', url: $this->generateUrl(route: 'app_main'));
|
||||||
|
yield MenuItem::linkToDashboard(label: 'Dashboard', icon: 'fa fa-dashboard');
|
||||||
|
yield MenuItem::linkToCrud(label: 'Projects', icon: 'fa fa-file-code-o', entityFqcn: Projects::class);
|
||||||
|
yield MenuItem::linkToCrud(label: 'Users', icon: 'fa fa-users', entityFqcn: User::class);
|
||||||
|
yield MenuItem::linkToCrud(label: 'Quotes', icon: 'fa fa-quote-left', entityFqcn: Quotes::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configureUserMenu(UserInterface $user): UserMenu
|
||||||
|
{
|
||||||
|
if (!$user instanceof User) {
|
||||||
|
throw new Exception(message: 'Wrong User!');
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::configureUserMenu(user: $user)
|
||||||
|
->setAvatarUrl(url: $user->getAvatar());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function configureActions(): Actions
|
||||||
|
{
|
||||||
|
return parent::configureActions()
|
||||||
|
->add(pageName: Crud::PAGE_INDEX, actionNameOrObject: Action::DETAIL);
|
||||||
|
}
|
||||||
|
|
||||||
public function configureDashboard(): Dashboard
|
|
||||||
{
|
|
||||||
return Dashboard::new()
|
|
||||||
->setTitle(title: '24unix Admin');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function configureMenuItems(): iterable
|
|
||||||
{
|
|
||||||
yield MenuItem::linkToDashboard(label: 'Dashboard', icon: 'fa fa-dashboard');
|
|
||||||
yield MenuItem::linkToCrud(label: 'Projects', icon: 'fa fa-file-code-o', entityFqcn: Projects::class);
|
|
||||||
yield MenuItem::linkToCrud(label: 'Users', icon: 'fa fa-users', entityFqcn: User::class);
|
|
||||||
yield MenuItem::linkToCrud(label: 'Quotes', icon: 'fa fa-quote-left', entityFqcn: Quotes::class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue