-
Notifications
You must be signed in to change notification settings - Fork 90
Refactored to work with zend-servicemanager v3 #36
Refactored to work with zend-servicemanager v3 #36
Conversation
03971aa
to
d4acce7
Compare
82d6c0d
to
2ab1a2f
Compare
- All factories implementing `FactoryInterface` and/or `AbstractFactoryInterface` were updated to the new interface signatures. - All plugin managers were updated to the new `AbstractPluginManager` changes. Whenever possible, they were rewritten to remove invokables and instead define factories and/or aliases. - Added the `RouteInvokableFactory`, which acts both as a specialized invokable factory for route implementations (as they use a `::factory()` method for initialization vs a constructor), and an abstract factory for handling FQCN route names. The `RoutePluginManager` composes this abstract factory by default. - `Application::init` was updated to pull the fully configured service manager from the `ServiceListener` after loading modules. - The `DispatchListener` now receives its controller manager instance during instantiation. - Separated router factory into 3: - `ConsoleRouterFactory` will create a console router - `HttpRouterFactory` will create an HTTP router - `RouterFactory` delegates to the above two, based on status of `Console::isConsole()` The above makes it possible to specify the specific router type you want to use via configuration, making testing possible. - Refactored the ViewManager implementations. Previously, the view managers were adding services and aliases to the service manager duing their bootstrap listeners; with the SM now immutable, that does not make sense, and, in fact, leads to errors. In all cases where object creation was occuring, the code was moved to new factories, which the view manager implementations can now pull specifically. Aliases for these were added where appropriate. However, I stopped short of adding factories for general services such as `DefaultRenderingStrategy` as the implementations differ enough that having such a factory mutate based on the selected view manager would require type-hinting to consume the services regardless. - New integration tests for `Application` were written to ensure the SM is in correct state for `bootstrap()` and `run()`, and that the service listener <-> service manager dance is correctly managed.
2ab1a2f
to
a46be7d
Compare
Decrease in test coverage is principally from disabling a number of tests due to the components they integrate with not yet being updated to zend-servicemanager v3 (notably: zend-i18n and zend-form). In most cases, I've added tests. |
Ping @zendframework/community-review-team — finally have the zend-servicemanager integration done! |
Fixed upstream in packagist repo.
return false; | ||
} | ||
|
||
if (! is_subclass_of($routeName, RouteInterface::class)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about using $routeName instanceof RouteInterface
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$routeName is string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot use instanceof as $routeName is the string class name, not an
object instance.
On Oct 9, 2015 5:33 AM, "Abdul Malik Ikhsan" notifications@github.com
wrote:
In src/Router/RouteInvokableFactory.php
#36 (comment):
- /**
\* Can we create a route instance with the given name?
*
\* Only works for FQCN $routeName values, for classes that implement RouteInterface.
*
\* @param ContainerInterface $container
\* @param string $routeName
\* @return bool
*/
- public function canCreateServiceWithName(ContainerInterface $container, $routeName)
- {
if (! class_exists($routeName)) {
return false;
}
if (! is_subclass_of($routeName, RouteInterface::class)) {
how about using $routeName instanceof RouteInterface ?
—
Reply to this email directly or view it on GitHub
https://github.com/zendframework/zend-mvc/pull/36/files#r41617243.
], | ||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be this removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still trying to decide what to do with it; forms will likely be optional, but we don't have a documented way to register the abstract factory yet. Once I have a plan, yes, we'll likely remove it.
This patch updates zend-mvc to use the upcoming zend-servicemanager v3.
All factories implementing
FactoryInterface
and/orAbstractFactoryInterface
were updated to the new interface signatures.All plugin managers were updated to the new
AbstractPluginManager
changes. Whenever possible, they were rewritten to remove invokables and instead define factories and/or aliases.Added the
RouteInvokableFactory
, which acts both as a specialized invokable factory for route implementations (as they use a::factory()
method for initialization vs a constructor), and an abstract factory for handling FQCN route names. TheRoutePluginManager
composes this abstract factory by default.Application::init
was updated to pull the fully configured service manager from theServiceListener
after loading modules.The
DispatchListener
now receives its controller manager instance during instantiation.Separated router factory into 3:
ConsoleRouterFactory
will create a console routerHttpRouterFactory
will create an HTTP routerRouterFactory
delegates to the above two, based on status ofConsole::isConsole()
The above makes it possible to specify the specific router type you want to use via configuration, making testing possible.
Refactored the ViewManager implementations. Previously, the view managers were adding services and aliases to the service manager duing their bootstrap listeners; with the SM now immutable, that does not make sense, and, in fact, leads to errors.
In all cases where object creation was occuring, the code was moved to new factories, which the view manager implementations can now pull specifically. Aliases for these were added where appropriate. However, I stopped short of adding factories for general services such as
DefaultRenderingStrategy
as the implementations differ enough that having such a factory mutate based on the selected view manager would require type-hinting to consume the services regardless.New integration tests for
Application
were written to ensure the SM is in correct state forbootstrap()
andrun()
, and that the service listener <-> service manager dance is correctly managed.