checkPrivilege() public method

Check Privilege
public checkPrivilege ( )
Example #1
0
 * @param  string $module
 * @param  string $controller
 * @param  array  $params
 * @param  bool   $checkAccess
 * @return null|string
 * @throws ViewException
 */
return function ($module, $controller, $params = [], $checkAccess = false) {
    /**
     * @var View $this
     */
    try {
        if ($checkAccess) {
            try {
                $controllerInstance = new Controller($module, $controller);
                $controllerInstance->checkPrivilege();
            } catch (ForbiddenException $e) {
                return null;
            }
        }
    } catch (\Exception $e) {
        throw new ViewException('Url View Helper: ' . $e->getMessage());
    }
    if (null === $module) {
        $module = Request::getModule();
    }
    if (null === $controller) {
        $controller = Request::getController();
    }
    if (null === $params) {
        $params = Request::getParams();
Example #2
0
 /**
  * Do dispatch
  *
  * @param  string $module
  * @param  string $controller
  * @param  array  $params
  * @return Controller
  */
 protected function doDispatch($module, $controller, $params = [])
 {
     // @TODO: try to find custom controller class
     // create controller controller
     $controllerInstance = new Controller($module, $controller);
     // check HTTP Accept header
     $controllerInstance->checkAccept();
     // check HTTP method
     $controllerInstance->checkMethod();
     // check ACL privileges
     $controllerInstance->checkPrivilege();
     // run controller
     $controllerInstance->run($params);
     return $controllerInstance;
 }