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

Commit

Permalink
Updated usage of attach Event for ZF3
Browse files Browse the repository at this point in the history
  • Loading branch information
divix1988 authored Jan 26, 2017
1 parent 51f7ed8 commit e269bce
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions docs/05. Strategies.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ method of the `Module.php` class:
```php
public function onBootstrap(EventInterface $e)
{
$t = $e->getTarget();

$t->getEventManager()->attach(
$t->getServiceManager()->get('ZfcRbac\View\Strategy\UnauthorizedStrategy')
$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);
}
);
}
```
Expand All @@ -41,10 +45,14 @@ To register it, copy-paste this code into your Module.php class:
```php
public function onBootstrap(EventInterface $e)
{
$t = $e->getTarget();

$t->getEventManager()->attach(
$t->getServiceManager()->get('ZfcRbac\View\Strategy\RedirectStrategy')
$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);
}
);
}
```
Expand Down Expand Up @@ -80,10 +88,14 @@ To register it, copy-paste this code into your Module.php class:
```php
public function onBootstrap(EventInterface $e)
{
$t = $e->getTarget();

$t->getEventManager()->attach(
$t->getServiceManager()->get('ZfcRbac\View\Strategy\UnauthorizedStrategy')
$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);
}
);
}
```
Expand Down

0 comments on commit e269bce

Please sign in to comment.