forked from appwrite/appwrite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEvent.php
More file actions
136 lines (110 loc) 路 2.45 KB
/
Copy pathEvent.php
File metadata and controls
136 lines (110 loc) 路 2.45 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?php
namespace Appwrite\Event;
use Resque;
class Event
{
const DELETE_QUEUE_NAME = 'v1-deletes';
const DELETE_CLASS_NAME = 'DeletesV1';
const AUDITS_QUEUE_NAME = 'v1-audits';
const AUDITS_CLASS_NAME = 'AuditsV1';
const USAGE_QUEUE_NAME = 'v1-usage';
const USAGE_CLASS_NAME = 'UsageV1';
const MAILS_QUEUE_NAME = 'v1-mails';
const MAILS_CLASS_NAME = 'MailsV1';
const FUNCTIONS_QUEUE_NAME = 'v1-functions';
const FUNCTIONS_CLASS_NAME = 'FunctionsV1';
const WEBHOOK_QUEUE_NAME = 'v1-webhooks';
const WEBHOOK_CLASS_NAME = 'WebhooksV1';
const TASK_QUEUE_NAME = 'v1-tasks';
const TASK_CLASS_NAME = 'TasksV1';
const CERTIFICATES_QUEUE_NAME = 'v1-certificates';
const CERTIFICATES_CLASS_NAME = 'CertificatesV1';
/**
* @var string
*/
protected $queue = '';
/**
* @var string
*/
protected $class = '';
/**
* @var array
*/
protected $params = [];
/**
* Event constructor.
*
* @param string $queue
* @param string $class
*/
public function __construct(string $queue, string $class)
{
$this->queue = $queue;
$this->class = $class;
}
/**
* @param string $queue
* return $this
*/
public function setQueue(string $queue): self
{
$this->queue = $queue;
return $this;
}
/**
* @return string
*/
public function getQueue()
{
return $this->queue;
}
/**
* @param string $class
* return $this
*/
public function setClass(string $class): self
{
$this->class = $class;
return $this;
}
/**
* @return string
*/
public function getClass()
{
return $this->class;
}
/**
* @param string $key
* @param mixed $value
*
* @return $this
*/
public function setParam(string $key, $value): self
{
$this->params[$key] = $value;
return $this;
}
/**
* @param string $key
*
* @return mixed|null
*/
public function getParam(string $key)
{
return (isset($this->params[$key])) ? $this->params[$key] : null;
}
/**
* Execute Event.
*/
public function trigger(): void
{
Resque::enqueue($this->queue, $this->class, $this->params);
$this->reset();
}
public function reset(): self
{
$this->params = [];
return $this;
}
}