Jim Scherer <[EMAIL PROTECTED]> napisał(a):

> Instead of "repeating the same code all over controllers" you can always
> create your own login controller class
>
> class My_Controller_Login extends Zend_Controller_Action  {}
>
> and then extend from it controllers that require log in.
>
> class ConfidentialController extends My_Controller_Login {}

Better yet is to use interfaces and act upon them.

class ConfidentialController extends My_Abstract_Controller implements 
SecureController, DatabaseAccessController

Those interfaces may introduce interface contracts such as isSecure() for 
SecureController. Your Controller implementation may then decide if user 
has to be logged in or could just check if Controller implements 
SecureController to require him to be logged in in this case. Then there 
comes a DatabaseAccessController which could have a setupDatabase() 
interface function in order to prepare database connections. Etc.

You don't limit yourself to one option this way.

In fact, Zend_View could be refactored to use interfaces as well. Instead 
of:

            if (method_exists($this->_helper[$name], 'setView')) {
                $this->_helper[$name]->setView($this);
            }

It would be better to code against interfaces:

            if ($this->_helper[$name] implements ViewAware) {
                $this->_helper[$name]->setView($this);
            }


-- 
Martel Valgoerad aka Michal Minicki | [EMAIL PROTECTED] | 
http://aie.pl/martel.asc
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
"Idleness is not doing nothing. Idleness is being free to do anything." 
 -- Floyd Dell

Reply via email to