Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

The mvc event listener invalid for namespace if it's multi segment namespaces #274

Open
@leogitpro

Description

@leogitpro

There is a question for me.
On a module, Like the path: module/Application, module/Admin, etc...
Most of time. the module namespace is use: Application\, Admin\, and now I want make a module is common module for other project. So I rename the namespace to: Brand\Admin\ replace the old Admin\ like this.
And then. the question is happened. I tracking all the script flow. The event manager just register the auto namespace first segment for the event identifier. Like the Brand\Admin\ registered in the identifiers is Brand
So I register listener on a module's onBootstrap() can not been called.

Code to reproduce the issue

namespace Brand\Admin
class Module {
//.... other code
public function onBootstrap(MvcEvent $event) {

        $sharedEventManager = $event->getApplication()->getEventManager()->getSharedManager();
        $sharedEventManager->attach(__NAMESPACE__, MvcEvent::EVENT_DISPATCH, function ($e) {
            echo '<h1>Hello, Baby!</h1>';
        }, 9999);
        // The will be ok. the eventmanager auto register identifier AbstractActionController
        //$sharedEventManager->attach(Zend\Mvc\Controller\AbstractActionController::class, MvcEvent::EVENT_DISPATCH, function ($e) {
            //echo '<h1>Hello, Baby!</h1>';
        //}, 9999);
        // Or not use shared event manager, use eventManger is OK.
    }
}

Expected results

the never output hello, baby.

Actual results

The listener never been called.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions