Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.
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
16 changes: 8 additions & 8 deletions doc/book/cookbook/route-specific-pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
class ApiResourcePipelineDelegatorFactory implements DelegatorFactoryInterface
Copy link
Contributor

Choose a reason for hiding this comment

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

it is better to use DelegatorFactoryInterface from ServiceManager\Factory namespace so we use :

public function __invoke(
      ContainerInterface $container,
      $name,
      callable $callback,
      array $options = null
)

{
public function createDelegatorWithName(
ServiceLocatorInterface $container,
public function __invoke(
ContainerInterface $container,
$name,
$requestedName,
$callback
callable $callback,
array $options = null
) {
$pipeline = new MiddlewarePipe();

Expand Down Expand Up @@ -98,7 +98,7 @@ return [
'ValidationMiddleware' => '...',
'ApiResourceMiddleware' => '...',
],
'delegator_factories' => [
'delegators' => [
'ApiResourceMiddleware' => [
'ApiResourcePipelineDelegatorFactory',
],
Expand Down
22 changes: 12 additions & 10 deletions doc/book/cookbook/using-zend-form-view-helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
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;
}
}
Expand All @@ -111,13 +113,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,
],
Expand Down