Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用symfony3在弹出式rom控制器中抛出拒绝访问_Symfony_Access Denied - Fatal编程技术网

使用symfony3在弹出式rom控制器中抛出拒绝访问

使用symfony3在弹出式rom控制器中抛出拒绝访问,symfony,access-denied,Symfony,Access Denied,嘿,我正在构建一个symfonyweb应用程序,我有一个功能,可以检查当前用户是否具有执行控制器操作的权限 $controle = $this->get('Controles'); if(($controle->is_Granted('Paramétrage point de vente','Paramétrage',$this->getUser()))==false){ throw new AccessDeniedException(); } 但它抛出一个

嘿,我正在构建一个symfonyweb应用程序,我有一个功能,可以检查当前用户是否具有执行控制器操作的权限

$controle = $this->get('Controles');
if(($controle->is_Granted('Paramétrage point de vente','Paramétrage',$this->getUser()))==false){
         throw new AccessDeniedException();
}
但它抛出一个403拒绝访问错误页面,我希望它出现在弹出窗口中,所以我尝试使用getFlashBag方法

$this->get('session')->getFlashBag('Warning', 'You are not allowed to do that');
但浏览器会显示以下内容:

The connection has been reset

The connection to the server was reset while the page was loaded.
有人知道为什么或者其他方法抛出弹出窗口而不是异常吗

这是我的完整控制器

class PointVenteController extends Controller
{
    public function __construct()
    {
        $session = new Session();
        $session->set('module', 'Paramétrage');
        $session->set('page', 'Gestion des points de vente');
        $session->set('menu', 'Parametrage-menu.html.twig');
    }

    /**
     * @Route("/pointVente", name="pointVente_index",
     * defaults={"_risque" ="Paramétrage","_icon" = "fa fa-wrench", "_titre" = "Paramétrage point de vente", "_type" = "L", "_partie" = "Point de vente"  })
     * @Method("GET")
     */
    public function indexAction()
    {
        $this->get('session')->getFlashBag()->add('Warning', 'You are not allowed to do that');
        $controle = $this->get('Controles');
        if(($controle->is_Granted('Paramétrage point de vente','Paramétrage',$this->getUser()))==false){throw new AccessDeniedException('You are not allowed to do that !!');}
        $datatable = $this->get('app.datatable.Bureau');
        $datatable->buildDatatable();
        return $this->render('ParamBundle:Parametrage:PointVente/index.html.twig',array(
            'datatable' =>$datatable,
        ));
    }
}

要添加flash消息,您必须执行以下操作:$this->get('session')->getFlashBag()->add('Warning','您不允许这样做');我已经修好了,但还是不行:(你能给我们看看你的完整控制器吗?当然,我已经更新了我的帖子