1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the Cubiche package. |
5
|
|
|
* |
6
|
|
|
* Copyright (c) Cubiche |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Cubiche\Core\EventBus\Tests\Fixtures\Event; |
13
|
|
|
|
14
|
|
|
use Cubiche\Core\EventBus\Event\Event; |
15
|
|
|
use Cubiche\Core\EventBus\Event\EventSubscriberInterface; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* UserEventSubscriber class. |
19
|
|
|
* |
20
|
|
|
* @author Ivannis Suárez Jerez <[email protected]> |
21
|
|
|
*/ |
22
|
|
|
class UserEventSubscriber implements EventSubscriberInterface |
23
|
|
|
{ |
24
|
|
|
const FOO_EVENT = 'event.foo'; |
25
|
|
|
const BAR_EVENT = 'event.bar'; |
26
|
|
|
const USER_LOGIN = 'user.login'; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @param LoginUserEvent $event |
30
|
|
|
* |
31
|
|
|
* @return bool |
32
|
|
|
*/ |
33
|
|
|
public function onLogin(LoginUserEvent $event) |
34
|
|
|
{ |
35
|
|
|
$event->setEmail('[email protected]'); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @param LoginUserEvent $event |
40
|
|
|
* |
41
|
|
|
* @return bool |
42
|
|
|
*/ |
43
|
|
|
public function onLoginSuccess(LoginUserEvent $event) |
44
|
|
|
{ |
45
|
|
|
$event->setEmail('[email protected]'); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @param Event $event |
50
|
|
|
* |
51
|
|
|
* @return bool |
52
|
|
|
*/ |
53
|
|
|
public function onFoo(Event $event) |
|
|
|
|
54
|
|
|
{ |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @param Event $event |
59
|
|
|
* |
60
|
|
|
* @return bool |
61
|
|
|
*/ |
62
|
|
|
public function onBar(Event $event) |
|
|
|
|
63
|
|
|
{ |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* {@inheritdoc} |
68
|
|
|
*/ |
69
|
|
|
public static function getSubscribedEvents() |
70
|
|
|
{ |
71
|
|
|
return array( |
72
|
|
|
self::FOO_EVENT => 'onFoo', |
73
|
|
|
self::BAR_EVENT => array('onBar', 21), |
74
|
|
|
self::USER_LOGIN => array( |
75
|
|
|
array('onLogin', 100), array('onLoginSuccess', 50), |
76
|
|
|
), |
77
|
|
|
); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.