Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Symfony 2 controller beforeAction exist?

Tags:

php

symfony

Is there a method like beforeAction for Symfony 2 controllers? Also, is there a generic beforeAction for the entire bundle/project?

like image 437
Tower Avatar asked Feb 22 '23 18:02

Tower


1 Answers

No, unfortunately there isn't a preExecute equivalent in symfony2, but instead you have access to a more powerful events model.

This article explains how to add a listener.

The event you want to listen to is onCoreController

Also see: http://symfony.com/doc/2.0/book/internals.html#the-event-dispatcher

like image 105
JamesHalsall Avatar answered Mar 01 '23 22:03

JamesHalsall