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

Forwards compatibility with v3 releases #76

Merged

Conversation

weierophinney
Copy link
Member

This patch provides forwards compatibility with version 3 releases of zend-servicemanager and zend-eventmanager, vs v3-compatibility-only per previous changes on the develop branch. As such, it now targets a future 2.7.0 release vs a 3.0.0 release.

Changes include:

  • Updating versions, dependencies, and test matrices:
    • to set the version in the CHANGELOG to v2.7.0 and update to cover changes from this patch.
    • to set all dependencies to known-stable, forwards compatible versions.
    • to test against both v2 and v3 versions of zend-eventmanager, zend-servicemanager, and zend-stdlib, and v1/v2 versions of zend-hydrator, against all supported PHP versions.
  • Re-instating removed functionality:
    • all zend-di related factories and initializers were re-introduced in order to keep backwards compatibility.
    • the ConfigFactory was re-instated.
    • initializers for ServiceManagerAware and ServiceLocatorAware were re-introduced for backwards compatibility, but now emit deprecation notices when invoked.
  • Updating all factories:
    • to implement Zend\ServiceManager\FactoryInterface (v2 and v3) instead of Zend\ServiceManager\Factory\FactoryInterface (v3-only)
    • to re-introduce the createService() method, as a proxy to __invoke().
  • Updating all abstract factories:
    • to implement Zend\ServiceManager\AbstractFactoryInterface (v2 and v3) instead of Zend\ServiceManager\Factory\AbstractFactoryInterface (v3-only)
    • to re-name the canCreateServiceWithName() method to canCreate()
    • to create a new canCreateServiceWithName() method proxying to canCreate()
    • to renaming createServiceWithName() to __invoke()
    • to creating a new createServiceWithName() method proxying to __invoke().
  • Updating all plugin managers:
    • to re-add the flags for "auto add invokable class" and "share by default" where necessary.
    • to re-add the validation methods, one for each of v2 and v3.
    • to edit and revise default services in light of forwards compatibility.
  • Updating all service config classes:
    • to validate default service configuration in light of forwards compatibility.

The changes so far are in the source code only, not tests, and, as such, this is a work-in-progress.

TODO

  • Revert the changes to the ServiceListener/ServiceManagerConfig/Application dance, back to the v2 workflow.
  • Check and update all tests to ensure they reflect expected behaviors, and ensure the code passes.
  • Document the MiddlewareListener and RouteInvokableFactory.

- Sets new target version to be 2.7.0.
- Updates dependencies to known-stable, forwards-compatible versions.
- Updates test matrix:
  - Test against v2 and v3 versions.
  - Run each against each supported PHP version.
This patch re-introduces the following classes from the
`Zend\Mvc\Service` namespace, along with related tests:

- `ConfigFactory`
- `ControllerLoaderFactory`
- `DiAbstractServiceFactoryFactory`
- `DiFactory`
- `DiServiceInitializerFactory`
- `DiStrictAbstractServiceFactory`
- `DiStrictAbstractServiceFactoryFactory`

It also re-instates the `ServiceManagerAware` and `ServiceLocatorAware`
initializers in the `ServiceManagerConfig` class (though they will now
emit deprecation notices), and ensures that class properly defines
services such that they'll be accessible identically between v2 and v3
of zend-servicemanager.
…eners

Not necessary with shipped, stable versions of zend-servicemanager.
- Re-introduced `createService()` method, proxying to `__invoke()`.
- Re-defined invokables as aliases + invokable factories.
- Re-enabled form abstract factory.
- Ensured each extend the appropriate v2 interface/class, and implement
  the required methods for both v2 and v3.
- Added `setInvokableClass()` implementation to `RoutePluginManager` to
  mimic work in `configure()` for v2.
Updated all factories to ensure they work with both v2 and v3 of
zend-servicemanager. Primarily, this consisted of re-adding the
`createService()` method as a proxy to `__invoke()`.

Updated all abstract factories to ensure they implement both the v2 and v3
methods.

Updated all plugin managers to ensure they implement both the v2 and v3
methods, define appropriate default services, and utilize the v2 properties for
"auto add invokables" and "share by default".
- Defer until after testing the instance, to allow injection in
  retrieved instances (vs lazy-instantiated ones).
Restores behavior to be backwards compatible; if the event manager,
request, and/or response are not passed to the constructor, they are
pulled from the service manager.
…ibility

Removed previous workflow from v2 with regards to:

- instantiation and initial configuration of the SM
- Retrieving the SM from the ServiceListener post-module loading (no
  longer necessary)
- Require zend-authentication 2.5.3 or up (first version to allow zend-stdlib
  3.0 support)
These changes provide basic v3 compability, allowing the tests to at least run
(though not pass). In particular:

- The `ConfigFactory` was only targeting v2 previously; it's now
  forwards-compatible with v3.
- The `RoutePluginManager` had two issues:
  - `configure()` had the wrong visibility.
  - `setInvokableClass()` is a method that changes signature between v2 and v3.
    Since the logic in the `RoutePluginManager` duplicates that in v3, it was
    removed.
- The EventManager factory, and any tests that were instantiating and injecting
  an EventManager with a shared event manager, received updates to allow varying
  instantiation based on version. v2 does not accept a shared manager to the
  constructor, and requires injection via `setSharedManager()`; v3 requires
  injection via the constructor, and removes the `setSharedManager()` method
  entirely.
- Updated `Forward` plugin to work with both v2 and v3 API of
  `SharedEventManagerInterface::getListeners()`.
- `ViewHelperManagerFactory` updates:
  - Fixed typo when registering Doctype helper factory.
  - All override factories now pull the parent service locator when under
    zend-servicemanager v2.
- Throw `InvalidServiceException`, not `InvalidServiceNameException`, from
  `DiStrictAbstractServiceFactory` (latter does not exist in v3)
- Test fixes:
  - `config`, not `Config`, service
  - `Request`, not `request`, service
  - do not grab return value of mutators on SM instances
  - use Prophecy to get SM/plugin manager instances (ensuring that constructor
    arguments can be ignored)
@weierophinney weierophinney removed the WIP label Feb 28, 2016
@weierophinney weierophinney self-assigned this Feb 28, 2016
@weierophinney weierophinney merged commit 9bab442 into zendframework:develop Feb 28, 2016
weierophinney added a commit that referenced this pull request Feb 28, 2016
weierophinney added a commit that referenced this pull request Feb 28, 2016
@weierophinney weierophinney deleted the feature/forwards-compat branch February 28, 2016 16:42
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