-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEventController.php
More file actions
48 lines (43 loc) · 863 Bytes
/
EventController.php
File metadata and controls
48 lines (43 loc) · 863 Bytes
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
<?php
namespace App\Controller;
use PhpRest\Event\EventTrigger;
/**
* 事件驱动
*
* @path /event
*/
class EventController
{
/**
* 事件传参
*
* @route GET /something_delete
*/
public function somethingDelete()
{
$params = ['user' => ['name' => 'nij', 'age' => 12]];
EventTrigger::on('SomeThingDelete', $params);
return 'event.somethingDelete';
}
/**
* 触发多个事件
*
* @route GET /user_event
*/
public function userEvent()
{
EventTrigger::on('UserEventA');
EventTrigger::on('UserEventB');
return 'event.userEvent';
}
/**
* 异步事件处理
*
* @route GET /async_event
*/
public function asyncEvent()
{
EventTrigger::on('AsyncEvent');
return 'event.AsyncEvent';
}
}