/** * Show Calendar */ public function showAction(Employee $employee, $year, $month, $day) { $sc = $this->get('security.context'); $user = $sc->getToken()->getUser(); $userId = $user->getId(); if ($employee->getId() != $userId && !$sc->isGranted('ROLE_ADMIN') && !$sc->isGranted('ROLE_MDBOSS')) { throw new AccessDeniedException("Unauthorized Access"); } else { if ($sc->isGranted('ROLE_MDBOSS') && $employee->getId() != $userId) { $allRoles = $employee->getRoles(); $show = 0; foreach ($allRoles as $role) { if ($role->getRole() == 'ROLE_MEDIADESIGNER') { $show = 1; } } if ($show == 0) { throw new AccessDeniedException("Unauthorized Access"); } } } $calendar = $this->get('calendar'); $calendar->personalize($employee); return $this->render('TimetrackerBundle:Calendar:show.html.twig', compact('calendar', 'employee')); }
public function createDeleteForm(Log $log, Employee $employee) { return $this->createFormBuilder()->setAction($this->generateUrl('log_delete', ['log' => $log->getId(), 'employee' => $employee->getId()]))->setMethod('DELETE')->getForm(); }