-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEventController.php
More file actions
46 lines (41 loc) · 1.5 KB
/
EventController.php
File metadata and controls
46 lines (41 loc) · 1.5 KB
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
<?php
declare(strict_types=1);
namespace App\Controller;
use PhpRest2\Controller\Attribute\{Controller, Action, Summary};
use PhpRest2\Event\EventTrigger;
#[Controller('/event')]
class EventController
{
/***************************************************************************************
* 事件传参
**************************************************************************************/
#[Action('GET:/demo1')]
#[Summary('事件传参')]
public function demo1()
{
$params = ['user' => ['name' => 'nij', 'age' => 12]];
EventTrigger::on('SomeThingDelete', $params);
return 'event.somethingDelete';
}
/***************************************************************************************
* 触发多个事件
**************************************************************************************/
#[Action('GET:/demo2')]
#[Summary('触发多个事件')]
public function demo2()
{
EventTrigger::on('UserEventA');
EventTrigger::on('UserEventB');
return 'event.userEvent';
}
/***************************************************************************************
* 异步事件处理
**************************************************************************************/
#[Action('GET:/demo3')]
#[Summary('异步事件处理')]
public function demo3()
{
EventTrigger::on('AsyncEvent');
return 'event.AsyncEvent';
}
}