Skip to content

Commit

Permalink
Merge pull request #96 from rieschl/feat/controller-manager-factory
Browse files Browse the repository at this point in the history
Add `ControllerManager::class` as resolvable service
  • Loading branch information
Ocramius authored Feb 2, 2022
2 parents 3cce483 + e6ef0bc commit e001299
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 55 deletions.
106 changes: 54 additions & 52 deletions src/Service/ServiceListenerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Interop\Container\ContainerInterface;
use Laminas\ModuleManager\Listener\ServiceListener;
use Laminas\ModuleManager\Listener\ServiceListenerInterface;
use Laminas\Mvc\Controller\ControllerManager;
use Laminas\Mvc\View;
use Laminas\ServiceManager\Exception\ServiceNotCreatedException;
use Laminas\ServiceManager\Factory\FactoryInterface;
Expand All @@ -29,62 +30,63 @@ class ServiceListenerFactory implements FactoryInterface
*/
protected $defaultServiceConfig = [
'aliases' => [
'application' => 'Application',
'Config' => 'config',
'configuration' => 'config',
'Configuration' => 'config',
'HttpDefaultRenderingStrategy' => View\Http\DefaultRenderingStrategy::class,
'MiddlewareListener' => 'Laminas\Mvc\MiddlewareListener',
'request' => 'Request',
'response' => 'Response',
'RouteListener' => 'Laminas\Mvc\RouteListener',
'SendResponseListener' => 'Laminas\Mvc\SendResponseListener',
'View' => 'Laminas\View\View',
'ViewFeedRenderer' => 'Laminas\View\Renderer\FeedRenderer',
'ViewJsonRenderer' => 'Laminas\View\Renderer\JsonRenderer',
'ViewPhpRendererStrategy' => 'Laminas\View\Strategy\PhpRendererStrategy',
'ViewPhpRenderer' => 'Laminas\View\Renderer\PhpRenderer',
'ViewRenderer' => 'Laminas\View\Renderer\PhpRenderer',
'Laminas\Mvc\Controller\PluginManager' => 'ControllerPluginManager',
'Laminas\Mvc\View\Http\InjectTemplateListener' => 'InjectTemplateListener',
'Laminas\View\Renderer\RendererInterface' => 'Laminas\View\Renderer\PhpRenderer',
'Laminas\View\Resolver\TemplateMapResolver' => 'ViewTemplateMapResolver',
'Laminas\View\Resolver\TemplatePathStack' => 'ViewTemplatePathStack',
'Laminas\View\Resolver\AggregateResolver' => 'ViewResolver',
'Laminas\View\Resolver\ResolverInterface' => 'ViewResolver',
'application' => 'Application',
'Config' => 'config',
'configuration' => 'config',
'Configuration' => 'config',
'HttpDefaultRenderingStrategy' => View\Http\DefaultRenderingStrategy::class,
'MiddlewareListener' => 'Laminas\Mvc\MiddlewareListener',
'request' => 'Request',
'response' => 'Response',
'RouteListener' => 'Laminas\Mvc\RouteListener',
'SendResponseListener' => 'Laminas\Mvc\SendResponseListener',
'View' => 'Laminas\View\View',
'ViewFeedRenderer' => 'Laminas\View\Renderer\FeedRenderer',
'ViewJsonRenderer' => 'Laminas\View\Renderer\JsonRenderer',
'ViewPhpRendererStrategy' => 'Laminas\View\Strategy\PhpRendererStrategy',
'ViewPhpRenderer' => 'Laminas\View\Renderer\PhpRenderer',
'ViewRenderer' => 'Laminas\View\Renderer\PhpRenderer',
'Laminas\Mvc\Controller\PluginManager' => 'ControllerPluginManager',
'Laminas\Mvc\View\Http\InjectTemplateListener' => 'InjectTemplateListener',
'Laminas\View\Renderer\RendererInterface' => 'Laminas\View\Renderer\PhpRenderer',
'Laminas\View\Resolver\TemplateMapResolver' => 'ViewTemplateMapResolver',
'Laminas\View\Resolver\TemplatePathStack' => 'ViewTemplatePathStack',
'Laminas\View\Resolver\AggregateResolver' => 'ViewResolver',
'Laminas\View\Resolver\ResolverInterface' => 'ViewResolver',
'ControllerManager' => ControllerManager::class,
],
'invokables' => [],
'factories' => [
'Application' => ApplicationFactory::class,
'config' => 'Laminas\Mvc\Service\ConfigFactory',
'ControllerManager' => 'Laminas\Mvc\Service\ControllerManagerFactory',
'ControllerPluginManager' => 'Laminas\Mvc\Service\ControllerPluginManagerFactory',
'DispatchListener' => 'Laminas\Mvc\Service\DispatchListenerFactory',
'HttpExceptionStrategy' => HttpExceptionStrategyFactory::class,
'HttpMethodListener' => 'Laminas\Mvc\Service\HttpMethodListenerFactory',
'HttpRouteNotFoundStrategy' => HttpRouteNotFoundStrategyFactory::class,
'HttpViewManager' => 'Laminas\Mvc\Service\HttpViewManagerFactory',
'InjectTemplateListener' => 'Laminas\Mvc\Service\InjectTemplateListenerFactory',
'PaginatorPluginManager' => 'Laminas\Mvc\Service\PaginatorPluginManagerFactory',
'Request' => 'Laminas\Mvc\Service\RequestFactory',
'Response' => 'Laminas\Mvc\Service\ResponseFactory',
'ViewHelperManager' => 'Laminas\Mvc\Service\ViewHelperManagerFactory',
View\Http\DefaultRenderingStrategy::class => HttpDefaultRenderingStrategyFactory::class,
'ViewFeedStrategy' => 'Laminas\Mvc\Service\ViewFeedStrategyFactory',
'ViewJsonStrategy' => 'Laminas\Mvc\Service\ViewJsonStrategyFactory',
'ViewManager' => 'Laminas\Mvc\Service\ViewManagerFactory',
'ViewResolver' => 'Laminas\Mvc\Service\ViewResolverFactory',
'ViewTemplateMapResolver' => 'Laminas\Mvc\Service\ViewTemplateMapResolverFactory',
'ViewTemplatePathStack' => 'Laminas\Mvc\Service\ViewTemplatePathStackFactory',
'ViewPrefixPathStackResolver' => 'Laminas\Mvc\Service\ViewPrefixPathStackResolverFactory',
'Laminas\Mvc\MiddlewareListener' => InvokableFactory::class,
'Laminas\Mvc\RouteListener' => InvokableFactory::class,
'Laminas\Mvc\SendResponseListener' => SendResponseListenerFactory::class,
'Laminas\View\Renderer\FeedRenderer' => InvokableFactory::class,
'Laminas\View\Renderer\JsonRenderer' => InvokableFactory::class,
'Laminas\View\Renderer\PhpRenderer' => ViewPhpRendererFactory::class,
'Application' => ApplicationFactory::class,
'config' => 'Laminas\Mvc\Service\ConfigFactory',
ControllerManager::class => 'Laminas\Mvc\Service\ControllerManagerFactory',
'ControllerPluginManager' => 'Laminas\Mvc\Service\ControllerPluginManagerFactory',
'DispatchListener' => 'Laminas\Mvc\Service\DispatchListenerFactory',
'HttpExceptionStrategy' => HttpExceptionStrategyFactory::class,
'HttpMethodListener' => 'Laminas\Mvc\Service\HttpMethodListenerFactory',
'HttpRouteNotFoundStrategy' => HttpRouteNotFoundStrategyFactory::class,
'HttpViewManager' => 'Laminas\Mvc\Service\HttpViewManagerFactory',
'InjectTemplateListener' => 'Laminas\Mvc\Service\InjectTemplateListenerFactory',
'PaginatorPluginManager' => 'Laminas\Mvc\Service\PaginatorPluginManagerFactory',
'Request' => 'Laminas\Mvc\Service\RequestFactory',
'Response' => 'Laminas\Mvc\Service\ResponseFactory',
'ViewHelperManager' => 'Laminas\Mvc\Service\ViewHelperManagerFactory',
View\Http\DefaultRenderingStrategy::class => HttpDefaultRenderingStrategyFactory::class,
'ViewFeedStrategy' => 'Laminas\Mvc\Service\ViewFeedStrategyFactory',
'ViewJsonStrategy' => 'Laminas\Mvc\Service\ViewJsonStrategyFactory',
'ViewManager' => 'Laminas\Mvc\Service\ViewManagerFactory',
'ViewResolver' => 'Laminas\Mvc\Service\ViewResolverFactory',
'ViewTemplateMapResolver' => 'Laminas\Mvc\Service\ViewTemplateMapResolverFactory',
'ViewTemplatePathStack' => 'Laminas\Mvc\Service\ViewTemplatePathStackFactory',
'ViewPrefixPathStackResolver' => 'Laminas\Mvc\Service\ViewPrefixPathStackResolverFactory',
'Laminas\Mvc\MiddlewareListener' => InvokableFactory::class,
'Laminas\Mvc\RouteListener' => InvokableFactory::class,
'Laminas\Mvc\SendResponseListener' => SendResponseListenerFactory::class,
'Laminas\View\Renderer\FeedRenderer' => InvokableFactory::class,
'Laminas\View\Renderer\JsonRenderer' => InvokableFactory::class,
'Laminas\View\Renderer\PhpRenderer' => ViewPhpRendererFactory::class,
'Laminas\View\Strategy\PhpRendererStrategy' => ViewPhpRendererStrategyFactory::class,
'Laminas\View\View' => ViewFactory::class,
'Laminas\View\View' => ViewFactory::class,
],
];

Expand Down
4 changes: 2 additions & 2 deletions test/Application/InvalidControllerTypeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ public function prepareApplication()
$serviceConfig,
[
'aliases' => [
'ControllerLoader' => 'ControllerManager',
'ControllerLoader' => ControllerManager::class,
],
'factories' => [
'ControllerManager' => function ($services) {
ControllerManager::class => function ($services) {
return new ControllerManager($services, ['factories' => [
'bad' => function () {
return new stdClass();
Expand Down
2 changes: 1 addition & 1 deletion test/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ public function setupBadController($addService = true, $action = 'test')
$router->addRoute('bad', $route);

if ($addService) {
$this->serviceManager->setFactory('ControllerManager', function ($services) {
$this->serviceManager->setFactory(ControllerManager::class, function ($services) {
return new ControllerManager($services, ['factories' => [
'bad' => function () {
return new Controller\TestAsset\BadController();
Expand Down

0 comments on commit e001299

Please sign in to comment.