Issues

ZF-7350: Make Zend_Loader_PluginLoader to prefix agnostic (namespaces)

Issue Type: New Feature Created: 2009-07-22T06:31:59.000+0000 Last Updated: 2012-04-26T07:39:28.000+0000 Status: Resolved Fix version(s): - 1.10.2 (24/Feb/10)

Reporter: Giorgio Sironi (giorgiosironi) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Loader

Related issues: - ZF-11330

Attachments: - zf-7350-2.patch

Description

Zend_Loader_PluginLoader appends '_' to the prefixes added to it, preventing the use of namespaces classes as plugins. Making it prefix-agnostic allows it to load namespaced classes, by specification of a "My\View\Helper\" prefix.

Comments

Posted by Giorgio Sironi (giorgiosironi) on 2009-07-22T06:34:49.000+0000

Quick and dirty fix to allow the use of namespaced view helpers. This works only because since view helpers cannot be in subfolders and the basename is directly appended to the path. For other classes path calculation could be wrong.

Posted by Steven Rosato (ratius) on 2009-08-09T19:26:07.000+0000

The provided fix works well and does not seem to break the tests though that one must always append the \ at the end of the namespace prefix for exemple in resource loading in an ini file:

pluginPaths["My\Application\Resource\"] = "My/Application/Resource"

To optionnally provide the ending backslash strstr($prefix, '\') could be used but then again non subnamespaces would fail at that using

$pluginLoader->addPrefixPath('My', 'Path/To/My'); //My is a namespace

still the only quick solution remain but an end backslash must be provided.

$pluginLoader->addPrefixPath('My\', 'Path/To/My'); //My is a namespace

Don't know your thoughts on that maybe Giorgio's solution may prove the only one not breaking anything.

Posted by Steven Rosato (ratius) on 2009-08-09T19:29:28.000+0000

Edit (correction): though that one must always append the "\ \"

[second code snippet]:

and $pluginLoader->addPrefixPath('My\ \', 'Path/To/My'); //My is a namespace

Posted by Andy Thompson (at465) on 2010-02-07T11:46:58.000+0000

I also came across this issue as I'm starting to write my applications using proper namespaces. I tackled the issue using the same method. I can't see it having any problems considering \ has never been used as a class name character, and looking at the end character seems the most logical way to do this.

Since Zend_Loader has been modified to support PHP 5.3 namespaces in 1.10, I was hoping this could be implemented as a minor release?

Posted by Steven Rosato (ratius) on 2010-02-08T11:20:44.000+0000

I'm still watching and hoping for this as it is my only patch that I need to apply each time Zend upgrades. It does not break unit tests and I, too, think it should be implemented in a minor release.

Posted by Giorgio Sironi (giorgiosironi) on 2010-02-23T07:55:24.000+0000

Updated patch for Zend Framework 1.10.1; hope this will be integrated soon.

Posted by Matthew Weier O'Phinney (matthew) on 2010-02-23T09:24:53.000+0000

Giorgio -- any chance I can get a unit test from you as well?

Posted by Giorgio Sironi (giorgiosironi) on 2010-02-23T11:21:27.000+0000

zf-7350-3: patch to use against /trunk with unit test added to PluginLoaderTest and necessary changes to Zend_Loader_PluginLoader. It incorporates the previous ones.

Posted by Matthew Weier O'Phinney (matthew) on 2010-02-23T11:50:44.000+0000

Patch applied to trunk and 1.10 release branch. Modified slightly to add a conditional to skip the test when PHP version is < 5.3.0.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts