public function process(WebhookEvent $event)
 {
     $data = $event->getData();
     if (!isset($data['user_id'])) {
         return null;
     }
     $user = $this->userRepository->find($data['user_id']);
     return ['event' => $event->getName(), 'user' => ['id' => $user->getId(), 'email' => $user->getEmail(), 'login' => $user->getLogin()], 'granted' => $data['granted'], 'rejected' => $data['rejected']];
 }
Пример #2
0
 public function vote(TokenInterface $token, $object, array $attributes)
 {
     if (!$object || !$this->supportsClass(get_class($object))) {
         return self::ACCESS_ABSTAIN;
     }
     $user = ctype_digit($token->getUser()) ? $this->userRepository->find((int) $token->getUser()) : null;
     foreach ($attributes as $attribute) {
         $attribute = strtolower($attribute);
         if ($this->supportsAttribute($attribute)) {
             $isGranted = call_user_func([$this, 'isGranted'], $attribute, $object, $user);
             return $isGranted ? self::ACCESS_GRANTED : self::ACCESS_DENIED;
         }
     }
     return self::ACCESS_ABSTAIN;
 }