ZF-9604: Action helpers with PHP namespaces do not work

Issue Type: Improvement Created: 2010-04-03T08:45:33.000+0000 Last Updated: 2010-12-18T12:55:48.000+0000 Status: Resolved Fix version(s): - 1.11.2 (30/Dec/10)

Reporter: Glen Ainscow (darkangel) Assignee: Ramon Henrique Ornelas (ramon) Tags: - Zend_Controller

Related issues: - ZF-10158



The issue is Zend_Controller_Action_HelperBroker::getHelper().

I think the helper is stored in the stack as "Namespace\MyHelper", and then the code tries to access it from the stack using the name "MyHelper", i.e., without the namespace.


Posted by Wil Moore III (wilmoore) (wilmoore) on 2010-11-21T02:44:13.000+0000

Actually, the problem is Zend_Controller_Action_Helper_Abstract#getName.

It assumes only "_" in the name but doesn't consider names with "\".

If you extend Zend_Controller_Action_Helper_Abstract and override getName(), your helpers will work. I've been using the following:

public function getName() {
    $full_class_name = get_class($this);

    if (strpos($full_class_name, '_') !== false) {
        $helper_name = strrchr($full_class_name, '_');
        return ltrim($helper_name, '_');
    } else {
        return $full_class_name;

BTW, the fix for issue ZF-10158 corrects this:

That being the case, this issue should be moved or closed.

Posted by Ramon Henrique Ornelas (ramon) on 2010-12-18T12:55:48.000+0000

Fixed with the issue ZF-9604.

Have you found an issue?

See the Overview section for more details.


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

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