Выбросить доступ, запрещенный в контроллере всплывающих окон, используя symfony3
Привет, я создаю веб-приложение Symfony, и у меня есть функция, которая проверяет, есть ли у текущего пользователя разрешение на выполнение действия контроллера или нет
$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,
));
}
}