-
Notifications
You must be signed in to change notification settings - Fork 0
/
AuthorizationEventListenerTrait.php
65 lines (57 loc) · 1.59 KB
/
AuthorizationEventListenerTrait.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/**
* @see https://github.com/dotkernel/dot-rbac-guard/ for the canonical source repository
* @copyright Copyright (c) 2017 Apidemia (https://www.apidemia.com)
* @license https://github.com/dotkernel/dot-rbac-guard/blob/master/LICENSE.md MIT License
*/
declare(strict_types = 1);
namespace Dot\Rbac\Guard\Event;
use Laminas\EventManager\EventManagerInterface;
use Laminas\EventManager\ListenerAggregateTrait;
/**
* Class AuthorizationEventListenerTrait
* @package Dot\Rbac\Guard\Event
*/
trait AuthorizationEventListenerTrait
{
use ListenerAggregateTrait;
public function attach(EventManagerInterface $events, $priority = 1)
{
$this->listeners[] = $events->attach(
AuthorizationEvent::EVENT_BEFORE_AUTHORIZATION,
[$this, 'onBeforeAuthorization'],
$priority
);
$this->listeners[] = $events->attach(
AuthorizationEvent::EVENT_AFTER_AUTHORIZATION,
[$this, 'onAfterAuthorization'],
$priority
);
$this->listeners[] = $events->attach(
AuthorizationEvent::EVENT_FORBIDDEN,
[$this, 'onForbidden'],
$priority
);
}
/**
* @param AuthorizationEvent $e
*/
public function onBeforeAuthorization(AuthorizationEvent $e)
{
// no-op
}
/**
* @param AuthorizationEvent $e
*/
public function onAfterAuthorization(AuthorizationEvent $e)
{
// no-op
}
/**
* @param AuthorizationEvent $e
*/
public function onForbidden(AuthorizationEvent $e)
{
// no-op
}
}