I've set up a test parent class in my Symfony 2 controller as follows:
<?php
namespace Zetcho\AmColAnBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class BaseController extends Controller
{
public function validateUser()
{
$user['first_name'] = "Name";
$user['signin'] = true;
return $user;
}
}
class DefaultController extends BaseController
{
public function indexAction()
{
$user = $this->validateUser();
$displayParms['user'] = $user;
return $this->render('ZetchoAmColAnBundle:Default:index.html.twig',$displayParms);
}
}
The code is in src/Zetcho/AmColAnBundle/Controller/DefaultController.php The test code works. I'd now like to move the parent class (BaseController) out of the controller file to its own so I can reuse it in my other controllers. I want to put it in the same directory as the other controllers and I'd like to declare it the same way as the Controller in the use statement above. What's the best/accepted way to do this in Symfony 2?