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. return $this->render('@Client/dashboard.html.twig');
  29. }
  30. public function companyIndexAction()
  31. {
  32. return $this->render('@Client/company/dashboard.html.twig');
  33. }
  34. public function profileAction()
  35. {
  36. /** @var User $user */
  37. $user = $this->getUser();
  38. if (!$user || !$user->hasRole('ROLE_CLIENT') || !($user instanceof User)) {
  39. throw new NotFoundHttpException('Access Denied!');
  40. }
  41. return $this->render('@Client/profile.html.twig', [
  42. 'client' => $user,
  43. ]);
  44. }
  45. public function companyProfileAction()
  46. {
  47. /** @var User $user */
  48. $user = $this->getUser();
  49. if (!$user || !$user->hasRole('ROLE_COMPANY') || !($user instanceof User)) {
  50. throw new NotFoundHttpException('Access Denied!');
  51. }
  52. return $this->render('@Client/company/profile.html.twig', [
  53. 'client' => $user,
  54. ]);
  55. }
  56. }