php - Symfony - Check if controller exists -


my situation: have navigatorcontroller triggered ajax requests, ,

$this->forward("controllername")

the request. how can check if controller exists based on controller name? of course, before actual forward happens , throws error when page controller not exists.

you can use controller_resolver service symfony uses in order check if controller exists.

public function indexaction(request $request) {     $request->attributes->set('_controller', 'appbundle\controller\examplecontroller::exampleaction');     try{         $this->get('debug.controller_resolver')->getcontroller($request);     } catch (\exception $e) {         $x = $e->getcode();     } } 

hope helps!


Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -