1 | <?php |
||
19 | class Worker |
||
20 | { |
||
21 | /** |
||
22 | * @var string |
||
23 | */ |
||
24 | private $id; |
||
25 | |||
26 | /** |
||
27 | * @var Listener |
||
28 | */ |
||
29 | private $listener; |
||
30 | |||
31 | /** |
||
32 | * @var string |
||
33 | */ |
||
34 | private $eventClass; |
||
35 | |||
36 | /** |
||
37 | * @var int |
||
38 | */ |
||
39 | private $priority; |
||
40 | |||
41 | /** |
||
42 | * @var string |
||
43 | */ |
||
44 | private $methodName; |
||
45 | |||
46 | /** |
||
47 | * Create new worker that will wake-up listener using event |
||
48 | * If priority is null the default (normal) will be used |
||
49 | * |
||
50 | * @param string $id |
||
51 | * @param Listener $listener |
||
52 | * @param string $methodName |
||
53 | * @param string $eventClass |
||
54 | * @param int $priority |
||
55 | */ |
||
56 | public function __construct($id, Listener $listener, $methodName, $eventClass, $priority = Priority::NORMAL) |
||
64 | 14 | ||
65 | 14 | /** |
|
66 | 14 | * @param Event $event |
|
67 | 14 | * |
|
68 | 14 | * @return WorkerResult |
|
69 | */ |
||
70 | public function run(Event $event) |
||
81 | |||
82 | 9 | /** |
|
83 | * @return string |
||
84 | */ |
||
85 | public function getId() |
||
89 | |||
90 | 9 | /** |
|
91 | * Get full worker name including class, method and priority. |
||
92 | */ |
||
93 | public function getName() |
||
101 | |||
102 | /** |
||
103 | * @return Listener |
||
104 | 3 | */ |
|
105 | public function getListener() |
||
109 | |||
110 | /** |
||
111 | * @return string |
||
112 | 9 | */ |
|
113 | public function getListenerClass() |
||
117 | |||
118 | /** |
||
119 | * @return string |
||
120 | 10 | */ |
|
121 | public function getMethod() |
||
125 | |||
126 | /** |
||
127 | * @return string |
||
128 | 12 | */ |
|
129 | public function getMethodName() |
||
133 | |||
134 | /** |
||
135 | * @return string |
||
136 | 12 | */ |
|
137 | public function getEventClass() |
||
141 | |||
142 | /** |
||
143 | * @return int |
||
144 | */ |
||
145 | public function getPriority() |
||
149 | |||
150 | /** |
||
151 | * @param $priority |
||
152 | * |
||
153 | * @return $this |
||
154 | 9 | */ |
|
155 | public function setPriority($priority) |
||
161 | |||
162 | /** |
||
163 | * {@inheritdoc} |
||
164 | */ |
||
165 | public function __toString() |
||
169 | } |