src/ClientBundle/Controller/DashboardController.php line 17

Open in your IDE?
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: laurentiu
  5. * Date: 21.09.2017
  6. * Time: 20:40
  7. */
  8. namespace ClientBundle\Controller;
  9. use AdminBundle\Controller\BaseController;
  10. use AdminBundle\Entity\User;
  11. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  12. class DashboardController extends BaseController
  13. {
  14. public function bounceAction() {
  15. $route = 'client_login';
  16. if ($user = $this->getUser()) {
  17. if (
  18. $user->hasRole('ROLE_CLIENT') ||
  19. $user->hasRole('ROLE_COMPANY')
  20. ) {
  21. $route = 'client_bookings';
  22. }
  23. }
  24. return $this->redirectToRoute($route);
  25. }
  26. public function indexAction()
  27. {
  28. $user = $this->getUser();
  29. if (
  30. !$user ||
  31. !$user->hasRole('ROLE_CLIENT') ||
  32. !($user instanceof User)
  33. ) {
  34. throw new NotFoundHttpException('Access Denied!');
  35. }
  36. return $this->render('@Client/dashboard.html.twig');
  37. }
  38. public function companyIndexAction()
  39. {
  40. $user = $this->getUser();
  41. if (
  42. !$user ||
  43. !$user->hasRole('ROLE_COMPANY') ||
  44. !($user instanceof User)
  45. ) {
  46. throw new NotFoundHttpException('Access Denied!');
  47. }
  48. return $this->render('@Client/company/dashboard.html.twig');
  49. }
  50. public function profileAction()
  51. {
  52. /** @var User $user */
  53. $user = $this->getUser();
  54. if (!$user || !$user->hasRole('ROLE_CLIENT') || !($user instanceof User)) {
  55. throw new NotFoundHttpException('Access Denied!');
  56. }
  57. return $this->render('@Client/profile.html.twig', [
  58. 'client' => $user,
  59. ]);
  60. }
  61. public function companyProfileAction()
  62. {
  63. /** @var User $user */
  64. $user = $this->getUser();
  65. if (!$user || !$user->hasRole('ROLE_COMPANY') || !($user instanceof User)) {
  66. throw new NotFoundHttpException('Access Denied!');
  67. }
  68. return $this->render('@Client/company/profile.html.twig', [
  69. 'client' => $user,
  70. ]);
  71. }
  72. }