Am Montag, den 22.10.2007, 04:14 -0400 schrieb Matthew Weier O'Phinney:
> it's because _forward() is a protected method in
> Zend_Controller_Action; you can't call it from a public instance of the
> object.
There are certainly good reasons to make _forward final and protected
and _redirect protected. Thus, I decided to create my own class
Quasda_Controller_Action_Helper_Abstract extends
Zend_Controller_Action_Helper_Abstract
{
which implements _forward and _redirect and acts a base class for all my
future action helpers. The implementation of these methods is in case of
_forward identically to the implementation in Zend_Controller_Action and
in case of _redirect I needed to use
Zend_Controller_Action_HelperBroker::getStaticHelper('Redirector');
to gain access to the redirector.
This works fine so far, what only bothers me, is that I have doubled
code in my application. A violation to the DRY convention. Isn't it a
desirable target to have access to regular "Action" methods in "Action"
helpers?
> The equivalent code is pretty simple:
>
> $this->getRequest()
> ->setModuleName($module)
> ->setControllerName($controller)
> ->setActionName($action)
> ->setParams($params)
> ->setDispatched(false);
This is actually a simplified implementation of _forward in
Zend_Controller_Action
Best regards
/Ralf
> The last line is the most important of them, as it sets the flag that
> the dispatch loop looks at in determining whether or not to iterate
> again.
>
> > Am Sonntag, den 21.10.2007, 21:38 -0500 schrieb Ralph Schindler:
> > > Ralf Kramer wrote:
> > >
> > > >
> > > > public function init()
> > > > {
> > > > Zend_Controller_Action_HelperBroker::addPrefix('Quasda_User_Helpers');
> > > > $helper = Zend_Controller_Action_HelperBroker::getHelper("User_Helper");
> > > > $helper->doSmth();
> > > > }
> > > >
> > >
> > >
> > > Try this:
> > >
> > > public function init()
> > > {
> > > Zend_Controller_Action_HelperBroker::addPrefix('Quasda_User_Helpers');
> > > $helper = $this->_helper->getHelper('User_Helper');
> > > $helper->doSmth();
> > > }
> > >
> > > Reason being is that you want to use the helper broker that is specific
> > > to the current ActionController. That way, the helper you are trying to
> > > use will have an instance of the ActionController itself.
> > >
> > > -ralph
> >
>