Convert AdminController to use Breadcrumb class
This commit is contained in:
parent
7e1badcc4a
commit
60558475f2
@ -7,6 +7,7 @@ use App\Entity\User;
|
|||||||
use App\Form\EditUserFormType;
|
use App\Form\EditUserFormType;
|
||||||
use App\Form\SupervisorFormType;
|
use App\Form\SupervisorFormType;
|
||||||
use App\Form\UserFormType;
|
use App\Form\UserFormType;
|
||||||
|
use App\Libs\Breadcrumb;
|
||||||
use App\Libs\NavList;
|
use App\Libs\NavList;
|
||||||
use App\Repository\UserRepository;
|
use App\Repository\UserRepository;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
@ -41,7 +42,7 @@ class AdminController extends AbstractController
|
|||||||
$this->navLinks,
|
$this->navLinks,
|
||||||
[
|
[
|
||||||
'breadcrumbs' => [
|
'breadcrumbs' => [
|
||||||
'Admin Dashboard'
|
new Breadcrumb($this->generateUrl('app_admin_dashboard'), 'Admin Dashboard')
|
||||||
],
|
],
|
||||||
'notifications' => $user->retrieveUnreadNotifications(),
|
'notifications' => $user->retrieveUnreadNotifications(),
|
||||||
]
|
]
|
||||||
@ -73,7 +74,7 @@ class AdminController extends AbstractController
|
|||||||
$this->navLinks,
|
$this->navLinks,
|
||||||
[
|
[
|
||||||
'breadcrumbs' => [
|
'breadcrumbs' => [
|
||||||
'User List'
|
new Breadcrumb($this->generateUrl('app_list_users'), 'List Users')
|
||||||
],
|
],
|
||||||
'users' => $users,
|
'users' => $users,
|
||||||
'notifications' => $user->retrieveUnreadNotifications(),
|
'notifications' => $user->retrieveUnreadNotifications(),
|
||||||
@ -130,6 +131,8 @@ class AdminController extends AbstractController
|
|||||||
$this->entityManager->persist($user);
|
$this->entityManager->persist($user);
|
||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
|
|
||||||
|
$this->addFlash('success', 'User added successfully');
|
||||||
|
|
||||||
return $this->redirectToRoute('app_list_users');
|
return $this->redirectToRoute('app_list_users');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +144,8 @@ class AdminController extends AbstractController
|
|||||||
$this->navLinks,
|
$this->navLinks,
|
||||||
[
|
[
|
||||||
'breadcrumbs' => [
|
'breadcrumbs' => [
|
||||||
'Add User'
|
new Breadcrumb($this->generateUrl('app_list_users'), 'User List'),
|
||||||
|
new Breadcrumb($this->generateUrl('app_add_user'), 'Add User')
|
||||||
],
|
],
|
||||||
'form' => $form,
|
'form' => $form,
|
||||||
'notifications' => $admin->retrieveUnreadNotifications(),
|
'notifications' => $admin->retrieveUnreadNotifications(),
|
||||||
@ -175,7 +179,6 @@ class AdminController extends AbstractController
|
|||||||
->setRate($form->get('rate')->getData())
|
->setRate($form->get('rate')->getData())
|
||||||
->setLevel($form->get('level')->getData());
|
->setLevel($form->get('level')->getData());
|
||||||
|
|
||||||
$this->entityManager->persist($user);
|
|
||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
|
|
||||||
return $this->redirectToRoute('app_list_users');
|
return $this->redirectToRoute('app_list_users');
|
||||||
@ -187,7 +190,8 @@ class AdminController extends AbstractController
|
|||||||
$this->navLinks,
|
$this->navLinks,
|
||||||
[
|
[
|
||||||
'breadcrumbs' => [
|
'breadcrumbs' => [
|
||||||
'Edit User'
|
new Breadcrumb($this->generateUrl('app_list_users'), 'User List'),
|
||||||
|
new Breadcrumb($this->generateUrl('app_edit_user', ['id' => $id]), 'Edit User')
|
||||||
],
|
],
|
||||||
'data' => $user,
|
'data' => $user,
|
||||||
'form' => $form,
|
'form' => $form,
|
||||||
@ -205,7 +209,7 @@ class AdminController extends AbstractController
|
|||||||
|
|
||||||
/** @var User $user */
|
/** @var User $user */
|
||||||
$user = $userRepo->find($id);
|
$user = $userRepo->find($id);
|
||||||
$prevSup = $this->entityManager->getRepository(Supervision::class)->findBy(['user' => $user]);
|
$prevSup = $this->entityManager->getRepository(Supervision::class)->findBy(['worker' => $user]);
|
||||||
|
|
||||||
$form = $this->createForm(SupervisorFormType::class);
|
$form = $this->createForm(SupervisorFormType::class);
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
@ -234,9 +238,10 @@ class AdminController extends AbstractController
|
|||||||
$this->navLinks,
|
$this->navLinks,
|
||||||
[
|
[
|
||||||
'breadcrumbs' => [
|
'breadcrumbs' => [
|
||||||
'Assign Supervisor'
|
new Breadcrumb($this->generateUrl('app_list_users'), 'User List'),
|
||||||
|
new Breadcrumb($this->generateUrl('app_assign_supervisor', ['id' => $id]), 'Assign Supervisor')
|
||||||
],
|
],
|
||||||
'data' => $user,
|
'user' => $user,
|
||||||
'form' => $form,
|
'form' => $form,
|
||||||
'supervisors' => $userRepo->getCaseManagers($admin->getCompany()),
|
'supervisors' => $userRepo->getCaseManagers($admin->getCompany()),
|
||||||
'notifications' => $admin->retrieveUnreadNotifications(),
|
'notifications' => $admin->retrieveUnreadNotifications(),
|
||||||
|
Loading…
Reference in New Issue
Block a user