-- keith Pope <[email protected]> wrote
(on Friday, 15 May 2009, 02:11 PM +0100):
> 2009/5/15 Vladas Diržys <[email protected]>:
> > I'm trying to setup Zend_Application to use module autoloader for view
> > helpers.
> > Earlier I used to add helper path manually:
> > $view->addHelperPath('path/to/views/helpers/', 'My_View_Helper');
> > Now as Zend_Application_Module_Autoloader has this information and it is
> > correctly bootstrapped, I expect that earlier declaration is redundant.
> > But at least in my application it doesn't work as I expect.
> > $view->helperTitle(); -- produces an error from PluginLoader.
> > I'm missing something or just doing something wrong?
> > PS.: $loader->load('helperTitle', 'viewhelper'); -- works.
>
> I too was wondering why the resource autoloader adds the helpers and
> filters for the modules
You still need to add the helper/filter paths to the view object. The
reason is that these are for _plugins_ -- i.e., behavior that can be
overridden elsewhere. It loops through the various prefix paths, and
looks for classes that begin with those prefixes. So, if you look for
"helperTitle", it loops through the prefixes and builds the class name:
My_View_Helper_HelperTitle
Zend_View_Helper_HelperTitle
and scans the directories associated with each prefix until it's able to
load a file and the class with that fully qualified name is loaded.
Autoloading helps speed this up -- instead of needing to scan the paths
for a given prefix, it can now likely autoload the class, saving some
cycles in the PluginLoader.
--
Matthew Weier O'Phinney
Project Lead | [email protected]
Zend Framework | http://framework.zend.com/