From d56d941f1bbe48ff307248685f2f7dbd0ee9a8e6 Mon Sep 17 00:00:00 2001 From: maks feltrin Date: Fri, 20 May 2016 00:44:59 +0200 Subject: [PATCH 1/5] fix delegators config key --- doc/book/cookbook/using-zend-form-view-helpers.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/book/cookbook/using-zend-form-view-helpers.md b/doc/book/cookbook/using-zend-form-view-helpers.md index bc104952..6b69f56c 100644 --- a/doc/book/cookbook/using-zend-form-view-helpers.md +++ b/doc/book/cookbook/using-zend-form-view-helpers.md @@ -111,13 +111,13 @@ The above creates an instance of the `Zend\Form\View\HelperConfig` class, uses it to configure the already created `Zend\View\HelperPluginManager` instance, and then returns the plugin manager instance. -From here, you'll add a `delegator_factories` configuration key in your +From here, you'll add a `delegators` configuration key in your `config/autoload/templates.global.php` file: ```php return [ 'dependencies' => [ - 'delegator_factories' => [ + 'delegators' => [ Zend\View\HelperPluginManager::class => [ Your\Application\FormHelpersDelegatorFactory::class, ], From 551550bd60fc57e502afb4560128cc1516edfb64 Mon Sep 17 00:00:00 2001 From: maks feltrin Date: Fri, 16 Sep 2016 21:47:50 +0200 Subject: [PATCH 2/5] FormHelpersDelegatorFactory implements DelegatorFactoryInterface as suggested here https://github.com/zendframework/zend-expressive/pull/346#issuecomment-247117249 --- doc/book/cookbook/using-zend-form-view-helpers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/book/cookbook/using-zend-form-view-helpers.md b/doc/book/cookbook/using-zend-form-view-helpers.md index 6b69f56c..3685a6c6 100644 --- a/doc/book/cookbook/using-zend-form-view-helpers.md +++ b/doc/book/cookbook/using-zend-form-view-helpers.md @@ -91,7 +91,7 @@ use Zend\Form\View\HelperConfig; use Zend\ServiceManager\DelegatorFactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; -class FormHelpersDelegatorFactory +class FormHelpersDelegatorFactory implements DelegatorFactoryInterface { public function createDelegatorWithName( ServiceLocatorInterface $container, From 970003ca694e2545902477214de271530cb6ef6e Mon Sep 17 00:00:00 2001 From: maks feltrin Date: Fri, 16 Sep 2016 21:50:56 +0200 Subject: [PATCH 3/5] fix delegators config key and implement DelegatorFactoryInterface --- doc/book/cookbook/route-specific-pipeline.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/book/cookbook/route-specific-pipeline.md b/doc/book/cookbook/route-specific-pipeline.md index 09cb551c..3d8cf45a 100644 --- a/doc/book/cookbook/route-specific-pipeline.md +++ b/doc/book/cookbook/route-specific-pipeline.md @@ -62,7 +62,7 @@ use Zend\ServiceManager\DelegatorFactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; use Zend\Stratigility\MiddlewarePipe; -class ApiResourcePipelineDelegatorFactory +class ApiResourcePipelineDelegatorFactory implements DelegatorFactoryInterface { public function createDelegatorWithName( ServiceLocatorInterface $container, @@ -98,7 +98,7 @@ return [ 'ValidationMiddleware' => '...', 'ApiResourceMiddleware' => '...', ], - 'delegator_factories' => [ + 'delegators' => [ 'ApiResourceMiddleware' => [ 'ApiResourcePipelineDelegatorFactory', ], From 4665f374b4c33be505e45a8d9a3370534315b405 Mon Sep 17 00:00:00 2001 From: maks feltrin Date: Sat, 17 Sep 2016 23:35:16 +0200 Subject: [PATCH 4/5] replace deprecated DelegatorFactoryInterface --- doc/book/cookbook/route-specific-pipeline.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/book/cookbook/route-specific-pipeline.md b/doc/book/cookbook/route-specific-pipeline.md index 3d8cf45a..a18248e0 100644 --- a/doc/book/cookbook/route-specific-pipeline.md +++ b/doc/book/cookbook/route-specific-pipeline.md @@ -58,17 +58,17 @@ middleware in order to change the instance or return an alternate instance. In this case, we'd do the latter. The following is an example: ```php -use Zend\ServiceManager\DelegatorFactoryInterface; -use Zend\ServiceManager\ServiceLocatorInterface; +use Zend\ServiceManager\Factory\DelegatorFactoryInterface; +use Interop\Container\ContainerInterface; use Zend\Stratigility\MiddlewarePipe; class ApiResourcePipelineDelegatorFactory implements DelegatorFactoryInterface { - public function createDelegatorWithName( - ServiceLocatorInterface $container, + public function __invoke( + ContainerInterface $container, $name, - $requestedName, - $callback + callable $callback, + array $options = null ) { $pipeline = new MiddlewarePipe(); From d1750086016cf0526e4ab7dc32dfd346f0e96c81 Mon Sep 17 00:00:00 2001 From: maks feltrin Date: Sat, 17 Sep 2016 23:37:54 +0200 Subject: [PATCH 5/5] replace deprecated DelegatorFactoryInterface added blank lines for clarity in the example (as it was done in the ApiResourcePipelineDelegatorFactory example): - retrieve the service - alter/extend the service - return the altered/extended service (should we add inline code comments?) --- .../cookbook/using-zend-form-view-helpers.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/doc/book/cookbook/using-zend-form-view-helpers.md b/doc/book/cookbook/using-zend-form-view-helpers.md index 3685a6c6..657fd845 100644 --- a/doc/book/cookbook/using-zend-form-view-helpers.md +++ b/doc/book/cookbook/using-zend-form-view-helpers.md @@ -87,21 +87,23 @@ You'll first need to create a delegator factory: ```php namespace Your\Application; +use Zend\ServiceManager\Factory\DelegatorFactoryInterface; +use Interop\Container\ContainerInterface; use Zend\Form\View\HelperConfig; -use Zend\ServiceManager\DelegatorFactoryInterface; -use Zend\ServiceManager\ServiceLocatorInterface; class FormHelpersDelegatorFactory implements DelegatorFactoryInterface { - public function createDelegatorWithName( - ServiceLocatorInterface $container, - $name, - $requestedName, - $callback + public function __invoke( + ContainerInterface $container, + $name, + callable $callback, + array $options = null ) { $helpers = $callback(); + $config = new HelperConfig(); $config->configureServiceManager($helpers); + return $helpers; } }