/** * @param string $actionName * @param array $params * @param AbstractCrudController $controller */ public function checkAccess($actionName, array $params, AbstractCrudController $controller) { $config = $controller->getPreparedConfig(); if (isset($config['security'])) { $security = $config['security']; if (isset($security['role'])) { $role = $security['role']; if (!$this->authorizationChecker->isGranted($role)) { $this->throwAccessDeniedException($role); } } if (isset($security['actions']) && isset($security['actions'][$actionName])) { $role = $security['actions'][$actionName]; if (is_callable($role)) { if (!call_user_func($role, $this->authorizationChecker, $params, $actionName)) { $this->throwAccessDeniedException($role); } } elseif (!$this->authorizationChecker->isGranted($role)) { $this->throwAccessDeniedException($role); } } } }
protected function setUp() { $this->controller = $this->createMock(AbstractCrudController::clazz()); $this->authorizationChecker = $this->createMock('Symfony\\Component\\Security\\Core\\Authorization\\AuthorizationCheckerInterface'); $this->interceptor = new SecurityControllerActionsInterceptor($this->authorizationChecker); }
protected function setUp() { $this->provider = $this->createMock(ContributorInterface::CLAZZ); $this->mgr = new InterceptorsManager($this->provider); $this->controller = $this->createMock(AbstractCrudController::clazz()); }