Ejemplo n.º 1
0
 public function isAdmin($user, AttendeeInterface $attendee)
 {
     if (!$user instanceof UserInterface) {
         return false;
     }
     return $user->equals($attendee->getUser()) || $user->equals($attendee->getEvent()->getOrganizer());
 }
 public function blame(AttendeeInterface $attendee)
 {
     $token = $this->securityContext->getToken();
     if (null === $token) {
         throw new \RuntimeException('You must configure a firewall for this route');
     }
     if ($this->securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
         $attendee->setUser($token->getUser());
     }
 }
Ejemplo n.º 3
0
 /**
  * Returns whether the $user can create the $attendee
  *
  * @param mixed             $user The user
  * @param AttendeeInterface $attendee The attendee
  *
  * @return boolean
  */
 protected function canCreate($user, AttendeeInterface $attendee)
 {
     $canCreate = false;
     $loggedInUser = is_object($user);
     if ($loggedInUser) {
         $event = $attendee->getEvent();
         $calendar = $event->getCalendar();
         $organizer = $event->getOrganizer();
         if ($calendar->isPublic() || $organizer->equals($user)) {
             $canCreate = true;
         }
     }
     return $canCreate;
 }