예제 #1
0
 /**
  * Check the permission's of a crud action
  *
  * @param ActionEvent $event
  * @throws AccessDeniedHttpException
  */
 public function onActionEvent(ActionEvent $event)
 {
     if (!in_array($event->getId(), $this->validIds)) {
         return;
     }
     if (false === $this->authorizationChecker->isGranted(array('RESOURCE_VOTE'), $event)) {
         throw new AccessDeniedHttpException(sprintf('Action %s is not allowed.', $event->getAction()), null, 403);
     }
 }
예제 #2
0
 /**
  * Injects the password encoder into user resources
  *
  * @param ActionEvent $event
  * @throws AccessDeniedHttpException
  */
 public function onActionEvent(ActionEvent $event)
 {
     if (!in_array($event->getId(), $this->validIds)) {
         return;
     }
     $resource = $event->getData()->getResource();
     if ($resource instanceof User) {
         $resource->setEncoder($this->encoderFactory->getEncoder($resource));
     }
 }