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

Ensure hydrators config is honored in non-zend-mvc contexts #59

Conversation

weierophinney
Copy link
Member

Per https://discourse.zendframework.com/t/validatormanager-not-calling-custom-validator-factory/109/5?u=matthew the hydrators config key is not honored currently unless the application is within a zend-mvc context. This is due to the fact that Zend\Hydrator\Module wires configuration for the Zend\ModuleManager\Listener\ServiceListener in order to push merged service configuration into the plugin during bootstrap; no similar logic is available when not in a zend-mvc context, however.

This patch fixes that situation by modifying the HydratorPluginManagerFactory to do the following:

  • If a ServiceListener service exists, it returns the plugin manager immediately (old behavior).
  • Otherwise, it checks for the config service, and, if found, a hydrators key with an array value. When found, it feeds that value to a Zend\ServiceManager\Config instance and uses that to configure the plugin manager before returning it.

Per https://discourse.zendframework.com/t/validatormanager-not-calling-custom-validator-factory/109/5?u=matthew
the `hydrators` config key is not honored currently unless the
application is within a zend-mvc context. This is due to the fact that
`Zend\Hydrator\Module` wires configuration for the
`Zend\ModuleManager\Listener\ServiceListener` in order to push merged
service configuration into the plugin during bootstrap; no similar logic
is available when not in a zend-mvc context, however.

This patch fixes that situation by modifying the
`HydratorPluginManagerFactory` to do the following:

- If a `ServiceListener` service exists, it returns the plugin manager
  immediately (old behavior).
- Otherwise, it checks for the `config` service, and, if found, a
  `hydrators` key with an array value. When found, it feeds that value
  to a `Zend\ServiceManager\Config` instance and uses that to configure
  the plugin manager before returning it.
@weierophinney weierophinney changed the title Ensure validators config is honored in non-zend-mvc contexts Ensure hydrators config is honored in non-zend-mvc contexts May 16, 2017
@weierophinney
Copy link
Member Author

Failing tests are against latest target, and are due to PHPUnit version mismatch issues; failures only affect HydratorPluginManagerCompatibilityTest; I've run the new tests manually with latest dependencies, and they pass as expected.

@weierophinney weierophinney added this to the 2.2.2 milestone May 17, 2017
weierophinney added a commit that referenced this pull request May 17, 2017
weierophinney added a commit that referenced this pull request May 17, 2017
@weierophinney weierophinney merged commit 3f9fa27 into zendframework:master May 17, 2017
weierophinney added a commit that referenced this pull request May 17, 2017
@weierophinney weierophinney deleted the hotfix/hydrators-service-config branch May 17, 2017 17:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant