ZF-2441: Loader_PluginLoader should allow loading of classes without using any prefix
Description
Sometimes it may be useful to not specify a prefix to the path. In my special situation i want to load models with the PluginLoader and I want to follow restrictions made for the Controller, so the Models are name like "Module_BarModel", but for the default-Module it will only called "FooModel". If an empty string is given as prefix _formatPrefix will ever append an underscore
protected function _formatPrefix($prefix)
{
return rtrim($prefix, '_') . '_';
}
So, if i try to loader "FooModel", it will (at least) search for "_FooModel". It seems to be more useful, if empty strings as prefix will stay empty strings.
protected function _formatPrefix($prefix)
{
return !empty($prefix) ? rtrim($prefix, '_') . '_' : '';
}
Comments
Posted by Wil Sinclair (wil) on 2008-03-31T16:07:17.000+0000
Please evaluate and assign as necessary.
Posted by Matthew Weier O'Phinney (matthew) on 2008-11-22T08:57:05.000+0000
One mission of Zend framework is to establish best practices. One aspect of plugin loading is to promote the idea of namespaced classes that can serve as replacements for existing functionality. These two combined bring us to the recommendation that plugin classes should have class prefixes to prevent naming collisions.