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

Do not raise an exception if a given plugin manager is not defined. #36

Conversation

weierophinney
Copy link
Member

The ServiceListener::onLoadModulesPost() listener raises an exception if a given plugin manager instance is unavailable, and does not exist in the application service manager. This impacts migrating the various plugin managers to their respective components:

  • If they are registered as part of the module configuration, but that component is not present, then an exception is raised.
  • We cannot add delegator factories on the ServiceListener from component module classes, as the ServiceListener is retrieved before loading modules.

One solution is to assume that if the plugin manager is not present, nothing needs to be done. This allows components to map the plugin loader services they expose via their Module classes, ensuring that once the listener triggers, it can access the service and configure it.

Incidentally, there is also a solution to components notifying the ServiceListener of plugin manager specifications already, via the init() method. As an example:

namespace Some\Component;

class Module
{
    public function init($event)
    {
        $container = $event->getParam('ServiceManager');
        $serviceListener = $container->get('ServiceListener');
        $serviceListener->addServiceManager(/* ... */);
    }
}

As components are expected to be listed early in the module list, this approach should be robust enough to ensure userland and third party modules (not components) registered later can configure the plugin manager.

The patch submitted ensures that in the off chance that a plugin manager is registered but has no service associated with it, exceptions need not be thrown.

The `ServiceListener::onLoadModulesPost()` listener raises an exception
if a given plugin manager instance is unavailable, and does not exist in
the application service manager. This impacts migrating the various
plugin managers to their respective components:

- If they are registered as part of the module configuration, but that
  component is not present, then an exception is raised.
- We cannot add delegator factories on the `ServiceListener` from
  component module classes, as the `ServiceListener` is retrieved
  *before* loading modules.

One solution is to assume that if the plugin manager is not present,
nothing needs to be done. This allows components to map the plugin
loader services they expose via their `Module` classes, ensuring that
once the listener triggers, it *can* access the service and configure
it.

Ideally, however, the component should also be able to notify the
`ServiceListener` of plugin managers; hopefully a later commit can
address that problem.
@weierophinney weierophinney merged commit a4247e1 into zendframework:master Jul 11, 2017
weierophinney added a commit that referenced this pull request Jul 11, 2017
…-managers

Do not raise an exception if a given plugin manager is not defined.
weierophinney added a commit that referenced this pull request Jul 11, 2017
weierophinney added a commit that referenced this pull request Jul 11, 2017
weierophinney added a commit that referenced this pull request Jul 11, 2017
Forward port #36

Conflicts:
	CHANGELOG.md
@weierophinney weierophinney deleted the hotfix/skip-unseeded-plugin-managers branch July 11, 2017 16:57
@weierophinney weierophinney added this to the 2.7.3 milestone Jul 11, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant