Skip to content
This repository has been archived by the owner on Jul 3, 2020. It is now read-only.

Commit

Permalink
Reviewer's updates
Browse files Browse the repository at this point in the history
Replaced listener attachment into shorter syntax + replaced interface object
  • Loading branch information
divix1988 authored Jan 28, 2017
1 parent f2e7c28 commit 2e9a977
Showing 1 changed file with 9 additions and 21 deletions.
30 changes: 9 additions & 21 deletions docs/05. Strategies.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,13 @@ By default, ZfcRbac does not register any strategy for you. The best place to re
method of the `Module.php` class:

```php
public function onBootstrap(EventInterface $e)
public function onBootstrap(MvcEvent $e)
{
$app = $e->getApplication();
$sm = $app->getServiceManager();

$e->getTarget()->getEventManager()->attach(
$e::EVENT_DISPATCH_ERROR,
function($e) use ($sm) {
return $sm->get('ZfcRbac\View\Strategy\UnauthorizedStrategy')->onError($e);
}
);
$listener = $sm->get(\ZfcRbac\View\Strategy\UnauthorizedStrategy::class);
$listener->attach($em);
}
```

Expand All @@ -43,17 +39,13 @@ URL as a query parameter.
To register it, copy-paste this code into your Module.php class:

```php
public function onBootstrap(EventInterface $e)
public function onBootstrap(MvcEvent $e)
{
$app = $e->getApplication();
$sm = $app->getServiceManager();

$e->getTarget()->getEventManager()->attach(
$e::EVENT_DISPATCH_ERROR,
function($e) use ($sm) {
return $sm->get('ZfcRbac\View\Strategy\RedirectStrategy')->onError($e);
}
);
$listener = $sm->get(\ZfcRbac\View\Strategy\RedirectStrategy::class);
$listener->attach($em);
}
```

Expand Down Expand Up @@ -86,17 +78,13 @@ This strategy allows your application to render a template on any unauthorized r
To register it, copy-paste this code into your Module.php class:

```php
public function onBootstrap(EventInterface $e)
public function onBootstrap(MvcEvent $e)
{
$app = $e->getApplication();
$sm = $app->getServiceManager();

$e->getTarget()->getEventManager()->attach(
$e::EVENT_DISPATCH_ERROR,
function($e) use ($sm) {
return $sm->get('ZfcRbac\View\Strategy\UnauthorizedStrategy')->onError($e);
}
);
$listener = $sm->get(\ZfcRbac\View\Strategy\UnauthorizedStrategy::class);
$listener->attach($em);
}
```

Expand Down

0 comments on commit 2e9a977

Please sign in to comment.