[Solar-talk] Helper stack

Paul M Jones pmjones at solarphp.com
Sat Jul 22 08:40:25 PDT 2006


On Jul 22, 2006, at 10:35 AM, Rodrigo Moraes wrote:

> A question about the helper stack. I'm wondering about the necessity
> of Vendor_Helper and Vendor_View_Helper directories. Following
> Solar_View_Helper, shouldn't Vendor_Helper be dropped for consistency
> to avoid confusion? I'm confused because of the results I get.
> Solar_Controller_Page says:
>
>         // add the helper classes to the view object.
>         // the order of searching will be:
>         // Vendor_App_Example_Helper_*, Vendor_App_Helper_*,
>         // Vendor_View_Helper_*, Solar_View_Helper_*
>
> But my helper stack is:
>     'stack' =>
>     array (
>       0 => 'Tipos_App_Blog_Helper_',
>       1 => 'Tipos_Helper_',

Hm, this is supposed to be Tipos_App_Helper, not Tipos_Helper.  I'll  
take a look at the code.

I'll also think about this ...

> I think this would be more straightforward in
> Controller_Page::_getLayout(), avoiding some strrpos() and substr():
>
>         // get directories list
>         $dirs = explode('_', $class);
>
>         // stack of helper classes
>         $helper = array();
>
>         // stack for directories
>         $stack = '';
>
>         // find all parent-level helpers
>         foreach($dirs as $dir) {
>             $stack .= $dir . '_';
>             $helper[] = $stack . 'Helper';
>         }
>
>         $helper = array_reverse($helper);
>
>         // add the helper class names to the view object
>         $layout->addHelperClass($helper);

... and see if it makes more sense than the more strictly-defined  
locations S_C_Page currently sets up.


> I wouldn't mind to not have Vendor_View_Helper, though.

Vendor_View_Helper should stay, as a fallback location for all view- 
helpers specific to that vendor.



--

Paul M. Jones  <http://paul-m-jones.com>

Solar: Simple Object Library and Application Repository
for PHP5.   <http://solarphp.com>

Savant: The simple, elegant, and powerful solution for
templates in PHP.   <http://phpsavant.com>




More information about the solar-talk mailing list