I have a simple and perhaps stupid question.
Using Symfony2 PHP framework i often work extending controllers like below (of course it depends from the kind of work):
class MainController extends Controller{
private $locale = array();
protected function Locale() {
$em = $this->getDoctrine()
->getManager();
$this->locale = $em->getRepository('CommonLanguageBundle:Language')
->findBy(
array('code' => $this->getRequest()
->getLocale()
)
);
// \Doctrine\Common\Util\Debug::dump($this->locale);
return $this->locale[0];
}
//..
}
class StoreController extends MainController{
function a_method() {
$data = $this->Locale()->getId();
//...
}
}
class DefaultController extends StoreController {
$data = $this->Locale()->getId();
//...
}
Is this a good practice?
Surfing on the web i found many articles but it isn't still so clear for me.
In the end, if it worked fine in Symfony2, would it be good in general for MVC pattern?