I seen this code just now:
Code: Select all
$controller = Zend_Controller_Front::getInstance();I see two possible reasons:
1. Because front controller should only ever have one instance -- hence the singleton -- is this really nessecary?
2. Because the developers anticipated it's global use and to avoid stuffing the instance in a registry they decided on giving it global access via a getInstance() method -- this is common in many Window'ing frameworks like MFC, OWL, etc. I personally think it was more for keeping with tradition than following a 'best practice'.
My own front controllers are pretty simple and would never really need to be accessed in the context of a controller/model or view which is probably why I fail to see why the use of a singleton. Do they really think component developers are going to try and create yet anotehr instance, when at the point of a controller the application is already booted up and rarin' to go?
Any one have any ideas on why they chose this approach?