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

Compatibility with latest develop branch of ServiceManager #48

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"zendframework/zend-servicemanager": "dev-develop as 2.6.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can use 3.0 now ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No; it'll be ^2.7 || ^3.0; however, any such changes need to wait; I'm doing a few migrations now, and seeing exactly what steps are needed, and what changes to make. For this particular component, and for zend-modulemanager, I'll actually be able to undo a lot of the changes we created previously, as they're accommodated by 2.7 and 3.0.

"zendframework/zend-hydrator": "~1.0",
"zendframework/zend-form": "~2.6",
"zendframework/zend-stdlib": "~2.7",
"zendframework/zend-stdlib": "dev-develop as 2.8.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without it composer complains about unresolved dependencies.

"zendframework/zend-psr7bridge": "^0.2",
"container-interop/container-interop": "^1.1"
},
Expand Down
2 changes: 1 addition & 1 deletion src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public static function init($configuration = [])
$smConfig = new Service\ServiceManagerConfig($smConfig);

$serviceManager = new ServiceManager($smConfig->toArray());
$serviceManager = $serviceManager->withConfig(['services' => [
$serviceManager = $serviceManager->configure(['services' => [
'ApplicationConfig' => $configuration,
]]);

Expand Down
2 changes: 1 addition & 1 deletion src/Router/Console/SimpleRouteStack.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class SimpleRouteStack extends BaseSimpleRouteStack
protected function init()
{
$routes = $this->routePluginManager;
$this->routePluginManager = $routes->withConfig(['invokables' => [
$this->routePluginManager = $routes->configure(['invokables' => [
'catchall' => __NAMESPACE__ . '\Catchall',
'simple' => __NAMESPACE__ . '\Simple',
]]);
Expand Down
2 changes: 1 addition & 1 deletion src/Router/Http/TreeRouteStack.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected function init()
$this->prototypes = new ArrayObject;

$routes = $this->routePluginManager;
$this->routePluginManager = $routes->withConfig([
$this->routePluginManager = $routes->configure([
'aliases' => [
'Chain' => 'chain',
'Hostname' => 'hostname',
Expand Down
6 changes: 3 additions & 3 deletions src/Router/RoutePluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ public function __construct(ContainerInterface $container, array $config = [])
* before passing to the parent.
*
* @param array $config
* @return void
* @return self
*/
protected function configure(array $config)
public function configure(array $config)
{
if (isset($config['invokables']) && ! empty($config['invokables'])) {
$aliases = $this->createAliasesForInvokables($config['invokables']);
Expand All @@ -86,7 +86,7 @@ protected function configure(array $config)
unset($config['invokables']);
}

parent::configure($config);
return parent::configure($config);
}

/**
Expand Down
9 changes: 5 additions & 4 deletions test/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ public function testBootstrapRegistersConfiguredMvcEvent()

public function setupPathController($addService = true)
{
$this->serviceManager->setAllowOverride(true);
$request = $this->serviceManager->get('Request');
$request->setUri('http://example.local/path');

Expand All @@ -257,7 +258,7 @@ public function setupPathController($addService = true)
],
]);
$router->addRoute('path', $route);
$services = $this->serviceManager->withConfig([
$services = $this->serviceManager->configure([
'aliases' => [
'Router' => 'HttpRouter',
],
Expand All @@ -268,7 +269,7 @@ public function setupPathController($addService = true)

$application = $this->setApplicationServiceManager($this->application, $services);
if ($addService) {
$services = $services->withConfig(['factories' => [
$services = $services->configure(['factories' => [
'ControllerManager' => function ($services) {
return new ControllerManager($services, ['factories' => [
'path' => function () {
Expand Down Expand Up @@ -299,7 +300,7 @@ public function setupActionController()
]);
$router->addRoute('sample', $route);

$services = $this->serviceManager->withConfig(['factories' => [
$services = $this->serviceManager->configure(['factories' => [
'ControllerManager' => function ($services) {
return new ControllerManager($services, ['factories' => [
'sample' => function () {
Expand Down Expand Up @@ -331,7 +332,7 @@ public function setupBadController($addService = true)

$application = $this->application;
if ($addService) {
$services = $this->serviceManager->withConfig(['factories' => [
$services = $this->serviceManager->configure(['factories' => [
'ControllerManager' => function ($services) {
return new ControllerManager($services, ['factories' => [
'bad' => function () {
Expand Down
2 changes: 1 addition & 1 deletion test/Controller/Plugin/ForwardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function testPluginWithoutControllerLocatorRaisesServiceNotCreatedExcepti

public function testDispatchRaisesDomainExceptionIfDiscoveredControllerIsNotDispatchable()
{
$controllers = $this->controllers->withConfig(['factories' => [
$controllers = $this->controllers->configure(['factories' => [
'bogus' => function () {
return new stdClass;
},
Expand Down
7 changes: 4 additions & 3 deletions test/Service/ControllerManagerFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function testCannotLoadControllerFromPeer()
public function testControllerLoadedCanBeInjectedWithValuesFromPeer()
{
$loader = $this->services->get('ControllerManager');
$loader = $loader->withConfig(['invokables' => [
$loader = $loader->configure(['invokables' => [
'ZendTest\Dispatchable' => TestAsset\Dispatchable::class,
]]);

Expand All @@ -91,8 +91,9 @@ public function testControllerLoadedCanBeInjectedWithValuesFromPeer()

public function testCallPluginWithControllerPluginManager()
{
$this->services->setAllowOverride(true);
$controllerPluginManager = $this->services->get('ControllerPluginManager');
$controllerPluginManager = $controllerPluginManager->withConfig([
$controllerPluginManager = $controllerPluginManager->configure([
'invokables' => [
'samplePlugin' => 'ZendTest\Mvc\Controller\Plugin\TestAsset\SamplePlugin',
],
Expand All @@ -101,7 +102,7 @@ public function testCallPluginWithControllerPluginManager()
$controller = new \ZendTest\Mvc\Controller\TestAsset\SampleController;
$controllerPluginManager->setController($controller);

$services = $this->services->withConfig(['services' => [
$services = $this->services->configure(['services' => [
'ControllerPluginManager' => $controllerPluginManager,
]]);

Expand Down
2 changes: 1 addition & 1 deletion test/Service/ServiceManagerConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function testEventManagerAwareInterfaceIsNotInjectedIfPresentButSharedMan
$events = new EventManager($this->services->get('SharedEventManager'));
TestAsset\EventManagerAwareObject::$defaultEvents = $events;

$services = $this->services->withConfig(['invokables' => [
$services = $this->services->configure(['invokables' => [
'EventManagerAwareObject' => TestAsset\EventManagerAwareObject::class,
]]);

Expand Down
6 changes: 3 additions & 3 deletions test/Service/ViewHelperManagerFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function emptyConfiguration()
*/
public function testDoctypeFactoryDoesNotRaiseErrorOnMissingConfiguration($config)
{
$services = $this->services->withConfig(['services' => [
$services = $this->services->configure(['services' => [
'config' => $config,
]]);
$manager = $this->factory->__invoke($services, 'ViewHelperManager');
Expand All @@ -60,7 +60,7 @@ public function testDoctypeFactoryDoesNotRaiseErrorOnMissingConfiguration($confi

public function testConsoleRequestsResultInSilentFailure()
{
$services = $this->services->withConfig(['services' => [
$services = $this->services->configure(['services' => [
'config' => [],
'Request' => new ConsoleRequest(),
]]);
Expand Down Expand Up @@ -88,7 +88,7 @@ public function testConsoleRequestWithBasePathConsole()
$this->markTestSkipped('Cannot force console context; skipping test');
}

$services = $this->services->withConfig(['services' => [
$services = $this->services->configure(['services' => [
'config' => [
'view_manager' => [
'base_path_console' => 'http://test.com',
Expand Down
4 changes: 2 additions & 2 deletions test/View/Console/ViewManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function testConsoleKeyWillOverrideDisplayExceptionAndExceptionMessage($c
$request = new ConsoleRequest();
$response = new ConsoleResponse();

$services = $this->services->withConfig(['services' => [
$services = $this->services->configure(['services' => [
'config' => $config,
'Request' => $request,
'EventManager' => $eventManager,
Expand Down Expand Up @@ -152,7 +152,7 @@ public function testConsoleDisplayExceptionIsTrue()
$request = new ConsoleRequest();
$response = new ConsoleResponse();

$services = $this->services->withConfig([
$services = $this->services->configure([
'services' => [
'config' => [],
'Request' => $request,
Expand Down