-- Marko Korhonen <[email protected]> wrote
(on Wednesday, 18 February 2009, 06:52 AM -0800):
> 
> Thanks for the great feedback!
> 
> I already converted many of my methods to actions helpers or moved them to
> controller plugins.
> 
> When I was exploring documentation and code I had a following idea:
> 
> In Zend_Controller_Action there is __call method:

I've already documented this potential idea some months ago in the
Zend_Controller 2.0 planning page:

    http://framework.zend.com/wiki/display/ZFDEV/Zend_Controller+2.0

We can start implementing this any time, just so long as the current
method of using the $_helper property to access helpers remains intact.


> public function __call($methodName, $args)
>     {
>         require_once 'Zend/Controller/Action/Exception.php';
>         if ('Action' == substr($methodName, -6)) {
>             $action = substr($methodName, 0, strlen($methodName) - 6);
>             throw new Zend_Controller_Action_Exception(sprintf('Action "%s"
> does not exist and was not trapped in __call()', $action), 404);
>         }
> 
>         throw new Zend_Controller_Action_Exception(sprintf('Method "%s" does
> not exist and was not trapped in __call()', $methodName), 500);
>     }
> 
> 
> Could it have updated so, it checks action helpers also? Something like
> this:
> 
> public function __call($methodName, $args)
>     {
>         require_once 'Zend/Controller/Action/Exception.php';
>         if ('Action' == substr($methodName, -6)) {
>             $action = substr($methodName, 0, strlen($methodName) - 6);
>             throw new Zend_Controller_Action_Exception(sprintf('Action "%s"
> does not exist and was not trapped in __call()', $action), 404);
>         }
>               else {
>                       try {
>                               return 
> call_user_func_array(array($this->_helper, $methodName), $args);
>                       } catch (Zend_Controller_Action_Exception $e) {
>                       }
>               }
> 
>         throw new Zend_Controller_Action_Exception(sprintf('Method "%s" does
> not exist and was not trapped in __call()', $methodName), 500);
>     }
> 
> 
> When I use action helpers in the code, lines look like this:
> $this->_helper->somehelper($arg1); // goes to helper's direct() method
> with this __call update this could be shorter:
> $this->somehelper($arg1);
> 
> I already tried it and it worked. But are there any other things to be
> considered?
> 
> 
> br, Marko
> -- 
> View this message in context: 
> http://www.nabble.com/Base-Controller-convienience-methods-tp22036897p22080392.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
> 

-- 
Matthew Weier O'Phinney
Software Architect       | [email protected]
Zend Framework           | http://framework.zend.com/

Reply via email to