I have a simple and possibly stupid question.
Using the Symfony2 framework, I often work on extending controllers, as shown below (of course, it depends on the type 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()
)
);
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 the Internet, I found many articles, but it’s still not so clear to me.
After all, if it works fine in Symfony2, would it be good at all for the MVC pattern?
source
share