/** * {@inheritdoc} */ protected function checkPermissions($entity, ObjectManager $em) { $loggedUserId = $this->securityFacade->getLoggedUserId(); if ($loggedUserId && $loggedUserId == $entity->getId()) { throw new ForbiddenException('self delete'); } parent::checkPermissions($entity, $em); }
/** * {@inheritdoc} */ protected function checkPermissions($entity, ObjectManager $em) { parent::checkPermissions($entity, $em); /** @var RoleRepository $roleRepo */ $roleRepo = $em->getRepository('OroUserBundle:Role'); if ($roleRepo->hasAssignedUsers($entity)) { throw new ForbiddenException('has users'); } }
/** * {@inheritdoc} */ protected function checkPermissions($entity, ObjectManager $em) { /** @var SystemCalendar|null $calendar */ $calendar = $entity->getSystemCalendar(); if ($calendar) { if ($calendar->isPublic()) { if (!$this->calendarConfig->isPublicCalendarEnabled()) { throw new ForbiddenException('Public calendars are disabled.'); } elseif (!$this->securityFacade->isGranted('oro_public_calendar_event_management')) { throw new ForbiddenException('Access denied.'); } } else { if (!$this->calendarConfig->isSystemCalendarEnabled()) { throw new ForbiddenException('System calendars are disabled.'); } elseif (!$this->securityFacade->isGranted('oro_system_calendar_event_management')) { throw new ForbiddenException('Access denied.'); } } } else { parent::checkPermissions($entity, $em); } }