Doctrine action parameters and objects in Symfony 2

We are launching a project built on top of Zend Framework 1.x, and are considering migrating to Symfony 2. We have a domain model mapped to Doctrine 2.

Our (custom) base controller class extends Zend_Controller_Action to provide a very convenient function inspired by Flow3:

Say I have this controller:

class UserController extends BaseController
{
    public function editAction(User $user)
    {
        // ...
    }
}

If I download this url:

/user/edit?user=123

The base controller will automatically load the User object with the identifier 123 and pass it as an argument to the editAction () method. If the user parameter is omitted or if the user with this identifier does not exist, an exception is thrown.

Is there such an implementation for Symfony 2, or is it possible to implement it, and how?

+3
1

All Articles