Front controller object in zend framewok
What is diff. between below objects of front controller and how to use it?
$this->bootstrap('frontController');
$frontContr开发者_开发问答oller = $this->getResource('frontController');
$front = Zend_Controller_Front::getInstance();
What is diff. between these two objects of front controller?
Both
$frontController = $this->getResource('frontController');
and
$front = Zend_Controller_Front::getInstance();
will return the same instance of Zend_Controller_Front. Its a singleton, so by definition there can only be one instance of that object. The difference is when you execute
$this->bootstrap('frontController');
you are insuring that the bootstrap has executed the front controller resource, Zend_Application_Resource_Frontcontroller by default.
IMO, use the first example in your bootstraps and resources, use the latter everywhere else. They both get you the same instance of the front controller, the only benefit to the first example is that lets the bootstrap know that the front controller is a dependency.
精彩评论