Throws an error if user has no access to the entity action.

@param array  $entityConfig
@param string $actionName
@param mixed  $subject
544346
public function checksUserAccess(array $entityConfig, string $actionName, $subject = null)
    {
        if ($this->adminMinimumRole && !$this->authorizationChecker->isGranted($this->adminMinimumRole)) {
            throw new AccessDeniedException(
                \sprintf('You must be granted %s role to access admin !', $this->adminMinimumRole)
            );
        }

        $requiredRole = $this->getRequiredRole($entityConfig, $actionName);

        if ($requiredRole && !$this->authorizationChecker->isGranted($requiredRole, $subject)) {
            throw new AccessDeniedException(
                \sprintf('You must be granted %s role to perform this entity action !', $requiredRole)
            );
        }
    }
431773
protected function _success(Subject $subject)
    {
        $subject->set(['success' => true, 'created' => true]);

        $this->_trigger('afterRegister', $subject);
        $this->setFlash('success', $subject);

        $redirectUrl = $this->config('redirectUrl');
        if ($redirectUrl === null && $this->_controller()->components()->has('Auth')) {
            $redirectUrl = $this->_controller()->Auth->config('loginAction');
        }

        return $this->_redirect($subject, $redirectUrl);
    }
739447
public function openSubjectAction(Subject $subject)
    {
        $forum = $subject->getCategory()->getForum();
        $this->checkAccess($forum);
        $this->manager->openSubject($subject);

        return new RedirectResponse(
            $this->generateUrl('claro_forum_subjects', array('category' => $subject->getCategory()->getId()))
        );
    }
1029556
public function adminUrl($subject, $action, $parameters = array())
    {
        if (is_object($subject)) {
            $className = get_class($subject);
        } elseif (is_string($subject)) {
            $className = $subject;
            if (strpos($className, ':') !== false) {
                list($namespace, $entity) = explode(':', $className);
                $className = $this->doctrine->getAliasNamespace($namespace) . '\\' . $entity;
            }
        } else {
            throw new InvalidArgumentException("Unsupported subject, need either an object or a string");
        }

        /** @var $admin \Sonata\AdminBundle\Admin\Admin */
        $admin = $this->sonata->getAdminByClass($className);
        if (!$admin) {
            // assume the string is an admincode.
            $admin = $this->sonata->getAdminByAdminCode($className);
        }

        if (!$admin) {
            throw new InvalidArgumentException("No admin found for {$className}");
        }
        if (is_object($subject)) {
            return $admin->generateObjectUrl($action, $subject, $parameters);
        } else {
            return $admin->generateUrl($action, $parameters);
        }
    }
1366426
private function action($action_name) {
    	// if no principal action is set yet or is the same
		if(!$this->Action || $action_name == $this->Action) {
			// set the main action
			$this->Action = $action_name;
		}
		// an action has already been set, this is impossible
		else { Throw new Exception("Query->action({$action_name}) : An incompatible action already exists : {$this->Action}"); }
    }
628574
private function addObjectRights($classname, array $config, UserSecurityIdentity $securityIdentity, $labelField = '_label')
    {
        $rights = $this->getActionsOnResources($config);
        foreach ((array) $rights as $resource => $actions) {
            if ('all' === $resource) {
                $this->addClassAcl($classname, $securityIdentity, $actions);
                $this->writeln(sprintf('    - Setting [%s] on all %s', implode(', ', $actions), $classname), OutputInterface::VERBOSITY_DEBUG);
                continue;
            }

            $object = $this->em->getRepository($classname)->findOneBy([$labelField => $resource]);
            if (null === $object) {
                $object = $this->em->find($classname, $resource);
            }

            if (null === $object) {
                $this->writeln(sprintf('    - Unknown %s `%s`', $classname, $resource), OutputInterface::VERBOSITY_DEBUG);
                continue;
            }

            $this->addObjectAcl($object, $securityIdentity, $actions);
            $this->writeln(sprintf('    - Setting [%s] on all %s `%s`', implode(', ', $actions), $classname, $resource), OutputInterface::VERBOSITY_DEBUG);
        }
    }
828995
public function authorizeAction(string $action, EntityContract $entity, Bag $parameters)
    {
        $errors = new Collection();

        $permission = $this->getPermission($action);

        if (!$this->getManager()->getAgent()->can($permission)) {
            $errors->push($this->newException(Tokens::NOT_AUTHORIZED, $permission));
        }

        return $errors;
    }
612722
private function ensureFieldConfigurationIsValid(array $entityConfig, string $entityName, string $section)
    {
        if (!isset($entityConfig[$section]['fields']) || !\count($entityConfig[$section]['fields'])) {
            return;
        }

        throw new ConflictingConfigurationException(\sprintf(
            '"%s" and "%s" are mutually conflicting. Pick just one of them in %s YAML configuration',
            'exclude_fields',
            'fields',
            \sprintf('easy_admin > entities > %s > %s', $entityName, $section)
        ));
    }
1100753
public function create_message($userName, $subject, $textBody, $action = null, $pmId = null)
    {
        try {
            $manager = $this->container->get('symbb.extension.tapatalk.manager.user');
            return $manager->createMessage($userName, $subject, $textBody, $action, $pmId);
        } catch (\Exception $exc) {
            return $this->errorResponse($exc);
        }
    }
444420
public function make($config = null)
    {
        try {
            return $this->_invokeCallable($this->_getFactoryCallback($config), [$config]);
        } catch (InvocationExceptionInterface $invocationException) {
            throw $this->_createCouldNotMakeException(
                $this->__('Could not make subject instance'),
                null,
                $invocationException,
                $this,
                $config
            );
        } catch (RootException $exception) {
            throw $this->_createFactoryException(
                $this->__('An error occurred while trying to make the subject instance'),
                null,
                $exception,
                $this
            );
        }
    }
602258
public function createMessage(Message $message, Subject $subject)
    {
    	$forum = $subject->getCategory()->getForum();
        $collection = new ResourceCollection(array($forum->getResourceNode()));

        if (!$this->sc->isGranted('post', $collection)) {
            throw new AccessDeniedHttpException($collection->getErrorsForDisplay());
        }

     	$user = $this->sc->getToken()->getUser();
        $message->setCreator($user);
        $message->setAuthor($user->getFirstName() . ' ' . $user->getLastName());
        $message->setSubject($subject);
        $this->om->persist($message);
        $this->om->flush();
		$this->dispatch(new CreateMessageEvent($message));
        $this->sendMessageNotification($message, $message->getCreator());

        return $message;
    }
1186303
protected function dispatchAssociationActionEvent($entity, $action, $target, $eventName)
    {
        $event = new AdminAssociationActionEvent($entity, $action, $target, $this->getUser());
        $this->get('event_dispatcher')->dispatch($eventName, $event);

        return $event;
    }
553022
public static <T> T doAs(final Subject subject,
         final java.security.PrivilegedExceptionAction<T> action)
         throws java.security.PrivilegedActionException {
      Stack<Subject> stack = SUBJECT.get();
      if (stack == null) {
         stack = new Stack<>();
         SUBJECT.set(stack);
      }
      stack.push(subject);
      try {
         return action.run();
      } catch (Exception e) {
         throw new PrivilegedActionException(e);
      } finally {
         stack.pop();
         if (stack.isEmpty()) {
            SUBJECT.remove();
         }
      }
   }
993445
public function authorize($action, $config = array())
    {
        if (is_string($config)) {
            $config = array($action => $config);
        }

        $config = AnConfig::unbox($config);

        $context = $this->_mixer->getRepository()->getCommandContext();

        $context->append($config)->append(array(
            'viewer' => get_viewer(),
            'mixer' => $this->_mixer,
        ));

        $authorizers = $this->_authorizers;
        $result = LibBaseDomainAuthorizerAbstract::AUTH_NOT_IMPLEMENTED;

        foreach ($authorizers as $authorizer) {
            $result = $authorizer->execute($action, $context);
            if ($result !== LibBaseDomainAuthorizerAbstract::AUTH_NOT_IMPLEMENTED) {
                break;
            }
        }

        $context->authorization = $result;

        $method = 'authorize'.ucfirst($action);

        if (method_exists($this->_mixer, $method)) {
            $ret = $this->_mixer->$method($context);

            if (!is_null($ret)) {
                $context->authorization = $ret;
            }
        }

        return $context->authorization;
    }
122097
public function customAction($entity, $action, $id = null, Request $request)
    {
        $entityConfig = $this->get('lin3s_admin.configuration.factory.entity')->createFor($entity);
        $entityObject = null;
        $repository = $this->get($entityConfig->repositoryServiceId());
        $entityConfig->loadRepository($repository);

        if ($id) {
            $entityObject = $repository->find($entityConfig, $id);
        }
        if ($id && !$entityObject) {
            throw $this->createNotFoundException(
                sprintf(
                    '%s not found for id "%s"',
                    $entityConfig->name(),
                    $id
                )
            );
        }
        try {
            $callableAction = $entityConfig->getAction($action);
        } catch (\Exception $e) {
            throw $this->createNotFoundException(
                sprintf(
                    'Action "%s" for entity "%s" not found, did you registered it in the config?',
                    $action,
                    $entity
                )
            );
        }

        return $callableAction->execute($entityObject, $entityConfig, $request);
    }
1149267
public function send( $to, $subject, $body )
	{
		// Debug advice:
		if ( \Sifo\Domains::getInstance()->getDebugMode() )
		{
			$this->_dispatchMailController( $to, $subject, $body );
		}
		return parent::send( $to, $subject, $body );
	}
907484
public function addSubject(\SplSubject $subject, $subjectName = null): self
    {
        if ($subjectName === null) {
            $subjectName = get_class($subject);
        }
        
        if (
            array_key_exists($subjectName, $this->subjectList) &&
            $this->subjectList[$subjectName] !== $subject
        ) {
            throw new \Exception(
                'A subject with the name '.$subjectName.' already exist.',
                self::ERR_ADD_SUBJECT_ALREADY_EXIST
            );
        }
        
        $this->subjectList[$subjectName] = $subject;
        
        return $this;
    }