zendframework / zend-modulemanager

ModuleManager component from Zend Framework
BSD 3-Clause "New" or "Revised" License
44 stars 27 forks source link

Hardcoded Zend\Mvc\Application identifier #15

Closed nuxwin closed 6 years ago

nuxwin commented 8 years ago

Hello ;

We are using the zend-modulemanager component (standalone) without using the zend-mvc component. Thus, we have our own iMSCP\Core\Application class (in our own namespace) which is responsible to initialize the application and trigger the bootstrap event as it is done in the Zend\Mvc\Application class from the zend-mvc component... The problem is that the module manager attach listeners on the bootstrap event using an hard coded identifier (Zend\Mvc\Application) like here: https://github.com/zendframework/zend-modulemanager/blob/master/src/Listener/LocatorRegistrationListener.php#L70

The problem with this approach is that we are forced either to use the zend-mvc module, or identify our event manager with the Zend\Mvc\Application identifier. From my point of view, the identifier should be configurable and not hard coded here. Right now, the module manager depends on the zend-mvc module...

@weierophinney Your thinking on this?

Thank you.

Xerkus commented 8 years ago

Seeing how listeners are specifically use Zend\Mvc\MvcEvent and registered from module manager factory in zend-mvc I think it would be proper for you to provide your own listeners instead.

Besides, upcoming v3 have explicit goal to remove zend-mvc dependency and there is only one place Zend\Mvc\Application identifier used: in OnBootstrapListener.

nuxwin commented 8 years ago

@Xerkus

First, thank for your fast answer ;)

Right now, I do


    /**
     * {@inheritdoc}
     */
    public function setEventManager(EventManagerInterface $events)
    {
        $events->setIdentifiers([
            __CLASS__,
            get_class($this),
            'Zend\Mvc\Application'
        ]);
        $this->events = $events;
        return $this;
    }

in our own iMSCP\Core\Application class which seem to solve the problem but... If I need to reimplement all module-manager listeners, I'll become crazy ;)

Your thinking about simply adding the Zend\Mvc\Application identifier to our event manager as done above?