@@ -55,15 +55,15 @@ discard block |
||
55 | 55 | $conf .= $this->generateProvidersPj(); |
56 | 56 | $conf .= $this->generatePeersPj(); |
57 | 57 | |
58 | - Util::fileWriteContent($this->config->path('asterisk.astetcdir') . '/pjsip.conf', $conf); |
|
58 | + Util::fileWriteContent($this->config->path('asterisk.astetcdir').'/pjsip.conf', $conf); |
|
59 | 59 | $pjConf = '[log_mappings]'."\n". |
60 | 60 | 'type=log_mappings'."\n". |
61 | 61 | 'asterisk_error = 0'."\n". |
62 | 62 | 'asterisk_warning = 2'."\n". |
63 | 63 | 'asterisk_debug = 1,3,4,5,6'."\n\n"; |
64 | 64 | |
65 | - file_put_contents($this->config->path('asterisk.astetcdir') . '/pjproject.conf', $pjConf); |
|
66 | - file_put_contents($this->config->path('asterisk.astetcdir') . '/sorcery.conf', ''); |
|
65 | + file_put_contents($this->config->path('asterisk.astetcdir').'/pjproject.conf', $pjConf); |
|
66 | + file_put_contents($this->config->path('asterisk.astetcdir').'/sorcery.conf', ''); |
|
67 | 67 | |
68 | 68 | $db = new AstDB(); |
69 | 69 | foreach ($this->data_peers as $peer) { |
@@ -84,13 +84,13 @@ discard block |
||
84 | 84 | */ |
85 | 85 | private function generateGeneralPj(): string |
86 | 86 | { |
87 | - $lang = $this->generalSettings['PBXLanguage']; |
|
87 | + $lang = $this->generalSettings['PBXLanguage']; |
|
88 | 88 | [$topology, $extipaddr, $exthostname, $subnets] = $this->getTopologyData(); |
89 | 89 | |
90 | 90 | $codecs = $this->getCodecs(); |
91 | 91 | $codecConf = ''; |
92 | - foreach ($codecs as $codec){ |
|
93 | - $codecConf.= "allow = {$codec}\n"; |
|
92 | + foreach ($codecs as $codec) { |
|
93 | + $codecConf .= "allow = {$codec}\n"; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | $pbxVersion = PbxSettings::getValueByKey('PBXVersion'); |
@@ -99,50 +99,50 @@ discard block |
||
99 | 99 | foreach ($subnets as $net) { |
100 | 100 | $natConf .= "local_net={$net}\n"; |
101 | 101 | } |
102 | - if ( ! empty($exthostname)) { |
|
102 | + if (!empty($exthostname)) { |
|
103 | 103 | $parts = explode(':', $exthostname); |
104 | - $natConf .= 'external_media_address=' . $parts[0] . "\n"; |
|
105 | - $natConf .= 'external_signaling_address=' . $parts[0] . "\n"; |
|
106 | - $natConf .= 'external_signaling_port=' . ($parts[1] ?? '5060'); |
|
107 | - } elseif ( ! empty($extipaddr)) { |
|
104 | + $natConf .= 'external_media_address='.$parts[0]."\n"; |
|
105 | + $natConf .= 'external_signaling_address='.$parts[0]."\n"; |
|
106 | + $natConf .= 'external_signaling_port='.($parts[1] ?? '5060'); |
|
107 | + } elseif (!empty($extipaddr)) { |
|
108 | 108 | $parts = explode(':', $extipaddr); |
109 | - $natConf .= 'external_media_address=' . $parts[0] . "\n"; |
|
110 | - $natConf .= 'external_signaling_address=' . $parts[0] . "\n"; |
|
111 | - $natConf .= 'external_signaling_port=' . ($parts[1] ?? '5060'); |
|
109 | + $natConf .= 'external_media_address='.$parts[0]."\n"; |
|
110 | + $natConf .= 'external_signaling_address='.$parts[0]."\n"; |
|
111 | + $natConf .= 'external_signaling_port='.($parts[1] ?? '5060'); |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
115 | - $conf = "[general] \n" . |
|
116 | - "disable_multi_domain=on\n" . |
|
117 | - "transport = udp \n\n" . |
|
115 | + $conf = "[general] \n". |
|
116 | + "disable_multi_domain=on\n". |
|
117 | + "transport = udp \n\n". |
|
118 | 118 | |
119 | - "[global] \n" . |
|
120 | - "type = global\n" . |
|
121 | - "endpoint_identifier_order=username,ip,anonymous\n" . |
|
122 | - "user_agent = mikopbx-{$pbxVersion}\n\n" . |
|
119 | + "[global] \n". |
|
120 | + "type = global\n". |
|
121 | + "endpoint_identifier_order=username,ip,anonymous\n". |
|
122 | + "user_agent = mikopbx-{$pbxVersion}\n\n". |
|
123 | 123 | |
124 | - "[anonymous]\n" . |
|
125 | - "type = endpoint\n" . |
|
124 | + "[anonymous]\n". |
|
125 | + "type = endpoint\n". |
|
126 | 126 | $codecConf. |
127 | 127 | "language={$lang}\n". |
128 | - "timers = no\n" . |
|
128 | + "timers = no\n". |
|
129 | 129 | "context = public-direct-dial\n\n". |
130 | 130 | |
131 | - "[transport-udp]\n" . |
|
132 | - "type = transport\n" . |
|
133 | - "protocol = udp\n" . |
|
131 | + "[transport-udp]\n". |
|
132 | + "type = transport\n". |
|
133 | + "protocol = udp\n". |
|
134 | 134 | "bind=0.0.0.0:{$this->generalSettings['SIPPort']}\n". |
135 | 135 | "{$natConf}\n\n". |
136 | 136 | |
137 | - "[transport-tcp]\n" . |
|
138 | - "type = transport\n" . |
|
139 | - "protocol = tcp\n" . |
|
137 | + "[transport-tcp]\n". |
|
138 | + "type = transport\n". |
|
139 | + "protocol = tcp\n". |
|
140 | 140 | "bind=0.0.0.0:{$this->generalSettings['SIPPort']}\n". |
141 | 141 | "{$natConf}\n\n". |
142 | 142 | ''; |
143 | 143 | |
144 | 144 | $varEtcDir = $this->config->path('core.varEtcDir'); |
145 | - file_put_contents($varEtcDir . '/topology_hash', md5($topology . $exthostname . $extipaddr. $this->generalSettings['SIPPort'])); |
|
145 | + file_put_contents($varEtcDir.'/topology_hash', md5($topology.$exthostname.$extipaddr.$this->generalSettings['SIPPort'])); |
|
146 | 146 | $conf .= "\n"; |
147 | 147 | |
148 | 148 | return $conf; |
@@ -154,19 +154,19 @@ discard block |
||
154 | 154 | * @return bool |
155 | 155 | */ |
156 | 156 | public function needAsteriskRestart():bool{ |
157 | - $di = Di::getDefault(); |
|
157 | + $di = Di::getDefault(); |
|
158 | 158 | if ($di === null) { |
159 | 159 | return false; |
160 | 160 | } |
161 | - $mikoPBXConfig = new MikoPBXConfig(); |
|
161 | + $mikoPBXConfig = new MikoPBXConfig(); |
|
162 | 162 | [$topology, $extipaddr, $exthostname] = $this->getTopologyData(); |
163 | 163 | |
164 | 164 | $generalSettings = $mikoPBXConfig->getGeneralSettings(); |
165 | - $now_hadh = md5($topology . $exthostname . $extipaddr. $generalSettings['SIPPort']); |
|
166 | - $old_hash = ''; |
|
165 | + $now_hadh = md5($topology.$exthostname.$extipaddr.$generalSettings['SIPPort']); |
|
166 | + $old_hash = ''; |
|
167 | 167 | $varEtcDir = $di->getShared('config')->path('core.varEtcDir'); |
168 | - if (file_exists($varEtcDir . '/topology_hash')) { |
|
169 | - $old_hash = file_get_contents($varEtcDir . '/topology_hash'); |
|
168 | + if (file_exists($varEtcDir.'/topology_hash')) { |
|
169 | + $old_hash = file_get_contents($varEtcDir.'/topology_hash'); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | return $old_hash !== $now_hadh; |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | continue; |
190 | 190 | } |
191 | 191 | $sub = new SubnetCalculator($lan_config['ipaddr'], $lan_config['subnet']); |
192 | - $net = $sub->getNetworkPortion() . '/' . $lan_config['subnet']; |
|
192 | + $net = $sub->getNetworkPortion().'/'.$lan_config['subnet']; |
|
193 | 193 | if ($if_data['topology'] === 'private' && in_array($net, $subnets, true) === false) { |
194 | 194 | $subnets[] = $net; |
195 | 195 | } |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | $conf = ''; |
228 | 228 | $reg_strings = ''; |
229 | 229 | $prov_config = ''; |
230 | - if ($this->data_providers===null){ |
|
230 | + if ($this->data_providers === null) { |
|
231 | 231 | $this->getSettings(); |
232 | 232 | } |
233 | 233 | foreach ($this->data_providers as $provider) { |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | |
237 | 237 | $need_register = $provider['noregister'] !== '1'; |
238 | 238 | if ($need_register) { |
239 | - $options = [ |
|
239 | + $options = [ |
|
240 | 240 | 'type' => 'auth', |
241 | 241 | 'username' => $provider['username'], |
242 | 242 | 'password' => $provider['secret'], |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | $reg_strings .= "[REG-AUTH-{$provider['uniqid']}]\n"; |
245 | 245 | $reg_strings .= Util::overrideConfigurationArray($options, $manual_attributes, 'registration-auth'); |
246 | 246 | |
247 | - $options = [ |
|
247 | + $options = [ |
|
248 | 248 | 'type' => 'registration', |
249 | 249 | // 'transport' => 'transport-udp', |
250 | 250 | 'outbound_auth' => "REG-AUTH-{$provider['uniqid']}", |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | } |
263 | 263 | |
264 | 264 | if ('1' !== $provider['receive_calls_without_auth']) { |
265 | - $options = [ |
|
265 | + $options = [ |
|
266 | 266 | 'type' => 'auth', |
267 | 267 | 'username' => $provider['username'], |
268 | 268 | 'password' => $provider['secret'], |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | } |
273 | 273 | |
274 | 274 | $defaultuser = (trim($provider['defaultuser']) === '') ? $provider['username'] : $provider['defaultuser']; |
275 | - if ( ! empty($defaultuser) && '1' !== $provider['receive_calls_without_auth']) { |
|
275 | + if (!empty($defaultuser) && '1' !== $provider['receive_calls_without_auth']) { |
|
276 | 276 | $contact = "sip:$defaultuser@{$provider['host']}:{$port}"; |
277 | 277 | } else { |
278 | 278 | $contact = "sip:{$provider['host']}:{$port}"; |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | 'minimum_expiration' => $this->generalSettings['SIPMinExpiry'], |
287 | 287 | 'default_expiration' => $this->generalSettings['SIPDefaultExpiry'], |
288 | 288 | ]; |
289 | - if($provider['qualify'] === '1'){ |
|
289 | + if ($provider['qualify'] === '1') { |
|
290 | 290 | $options['qualify_frequency'] = $provider['qualifyfreq']; |
291 | 291 | $options['qualify_timeout'] = '3.0'; |
292 | 292 | } |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | $prov_config .= "[{$provider['uniqid']}]\n"; |
295 | 295 | $prov_config .= Util::overrideConfigurationArray($options, $manual_attributes, 'aor'); |
296 | 296 | |
297 | - $options = [ |
|
297 | + $options = [ |
|
298 | 298 | 'type' => 'identify', |
299 | 299 | 'endpoint' => $provider['uniqid'], |
300 | 300 | 'match' => $provider['host'], |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | */ |
356 | 356 | public function generatePeersPj(): string |
357 | 357 | { |
358 | - if ($this->data_peers===null){ |
|
358 | + if ($this->data_peers === null) { |
|
359 | 359 | $this->getSettings(); |
360 | 360 | } |
361 | 361 | $lang = $this->generalSettings['PBXLanguage']; |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | $language = (trim($language) === '') ? 'en-en' : $language; |
370 | 370 | |
371 | 371 | $calleridname = (trim($peer['calleridname']) === '') ? $peer['extension'] : $peer['calleridname']; |
372 | - $busylevel = (trim($peer['busylevel']) === '') ? '1' : '' . $peer['busylevel']; |
|
372 | + $busylevel = (trim($peer['busylevel']) === '') ? '1' : ''.$peer['busylevel']; |
|
373 | 373 | |
374 | 374 | $options = [ |
375 | 375 | 'type' => 'auth', |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | 'conditions'=>'disabled="0"', |
522 | 522 | 'order' => 'type, priority', |
523 | 523 | ]; |
524 | - $codecs = Codecs::find($filter); |
|
524 | + $codecs = Codecs::find($filter); |
|
525 | 525 | foreach ($codecs as $codec_data) { |
526 | 526 | $arr_codecs[] = $codec_data->name; |
527 | 527 | } |
@@ -551,8 +551,8 @@ discard block |
||
551 | 551 | // Получим используемые кодеки. |
552 | 552 | $arr_data['codecs'] = $this->getCodecs(); |
553 | 553 | |
554 | - $context_id = preg_replace("/[^a-z\d]/iu", '', $sip_peer->host . $sip_peer->port); |
|
555 | - if ( ! isset($this->contexts_data[$context_id])) { |
|
554 | + $context_id = preg_replace("/[^a-z\d]/iu", '', $sip_peer->host.$sip_peer->port); |
|
555 | + if (!isset($this->contexts_data[$context_id])) { |
|
556 | 556 | $this->contexts_data[$context_id] = []; |
557 | 557 | } |
558 | 558 | $this->contexts_data[$context_id][$sip_peer->uniqid] = $sip_peer->username; |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | */ |
572 | 572 | private function getOutRoutes(): array |
573 | 573 | { |
574 | - if ($this->data_peers===null){ |
|
574 | + if ($this->data_peers === null) { |
|
575 | 575 | $this->getSettings(); |
576 | 576 | } |
577 | 577 | /** @var \MikoPBX\Common\Models\OutgoingRoutingTable $rout */ |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | */ |
607 | 607 | public function extensionGenContexts(): string |
608 | 608 | { |
609 | - if ($this->data_peers===null){ |
|
609 | + if ($this->data_peers === null) { |
|
610 | 610 | $this->getSettings(); |
611 | 611 | } |
612 | 612 | // Генерация внутреннего номерного плана. |
@@ -624,8 +624,8 @@ discard block |
||
624 | 624 | $contexts_data = $this->contexts_data[$provider['context_id']]; |
625 | 625 | if (count($contexts_data) === 1) { |
626 | 626 | $conf .= ExtensionsConf::generateIncomingContextPeers($provider['uniqid'], $provider['username'], ''); |
627 | - } elseif ( ! in_array($provider['context_id'], $contexts, true)) { |
|
628 | - $conf .= ExtensionsConf::generateIncomingContextPeers( |
|
627 | + } elseif (!in_array($provider['context_id'], $contexts, true)) { |
|
628 | + $conf .= ExtensionsConf::generateIncomingContextPeers( |
|
629 | 629 | $contexts_data, |
630 | 630 | null, |
631 | 631 | $provider['context_id'] |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | */ |
645 | 645 | public function extensionGenHints(): string |
646 | 646 | { |
647 | - if ($this->data_peers===null){ |
|
647 | + if ($this->data_peers === null) { |
|
648 | 648 | $this->getSettings(); |
649 | 649 | } |
650 | 650 | $conf = ''; |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | |
658 | 658 | public function extensionGenInternal(): string |
659 | 659 | { |
660 | - if ($this->data_peers===null){ |
|
660 | + if ($this->data_peers === null) { |
|
661 | 661 | $this->getSettings(); |
662 | 662 | } |
663 | 663 | // Генерация внутреннего номерного плана. |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | |
673 | 673 | public function extensionGenInternalTransfer(): string |
674 | 674 | { |
675 | - if ($this->data_peers===null){ |
|
675 | + if ($this->data_peers === null) { |
|
676 | 676 | $this->getSettings(); |
677 | 677 | } |
678 | 678 | // Генерация внутреннего номерного плана. |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | |
24 | 24 | public const SELECT_CDR_TUBE = 'select_cdr_tube'; |
25 | 25 | public const UPDATE_CDR_TUBE = 'update_cdr_tube'; |
26 | - protected int $maxProc=1; |
|
26 | + protected int $maxProc = 1; |
|
27 | 27 | |
28 | 28 | |
29 | 29 | private BeanstalkClient $client_queue; |
@@ -93,12 +93,12 @@ discard block |
||
93 | 93 | $result = json_decode($result_data, true); |
94 | 94 | if (file_exists($result)) { |
95 | 95 | $file_data = json_decode(file_get_contents($result), true); |
96 | - if(!is_dir($result)){ |
|
96 | + if (!is_dir($result)) { |
|
97 | 97 | Util::mwExec("rm -rf {$result}"); |
98 | 98 | } |
99 | 99 | $result = $file_data; |
100 | 100 | } |
101 | - if ( ! is_array($result) && ! is_object($result)) { |
|
101 | + if (!is_array($result) && !is_object($result)) { |
|
102 | 102 | return; |
103 | 103 | } |
104 | 104 | if (count($result) < 1) { |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | if (trim($row['recordingfile']) !== '') { |
116 | 116 | // Если каналов не существует с ID, то можно удалить временные файлы. |
117 | 117 | $p_info = pathinfo($row['recordingfile']); |
118 | - $fname = $p_info['dirname'] . '/' . $p_info['filename'] . '.wav'; |
|
118 | + $fname = $p_info['dirname'].'/'.$p_info['filename'].'.wav'; |
|
119 | 119 | if (file_exists($fname) && !is_dir($fname)) { |
120 | 120 | Util::mwExec("rm -rf {$fname}"); |
121 | 121 | } |
@@ -139,19 +139,19 @@ discard block |
||
139 | 139 | $row['answer'] = ''; |
140 | 140 | $billsec = 0; |
141 | 141 | |
142 | - if ( ! empty($row['recordingfile'])) { |
|
142 | + if (!empty($row['recordingfile'])) { |
|
143 | 143 | $p_info = pathinfo($row['recordingfile']); |
144 | 144 | $file_list = [ |
145 | - $p_info['dirname'] . '/' . $p_info['filename'] . '.mp3', |
|
146 | - $p_info['dirname'] . '/' . $p_info['filename'] . '.wav', |
|
147 | - $p_info['dirname'] . '/' . $p_info['filename'] . '_in.wav', |
|
148 | - $p_info['dirname'] . '/' . $p_info['filename'] . '_out.wav', |
|
145 | + $p_info['dirname'].'/'.$p_info['filename'].'.mp3', |
|
146 | + $p_info['dirname'].'/'.$p_info['filename'].'.wav', |
|
147 | + $p_info['dirname'].'/'.$p_info['filename'].'_in.wav', |
|
148 | + $p_info['dirname'].'/'.$p_info['filename'].'_out.wav', |
|
149 | 149 | ]; |
150 | 150 | foreach ($file_list as $file) { |
151 | - if ( ! file_exists($file)) { |
|
151 | + if (!file_exists($file)) { |
|
152 | 152 | continue; |
153 | 153 | } |
154 | - if(!is_dir($file)){ |
|
154 | + if (!is_dir($file)) { |
|
155 | 155 | Util::mwExec("rm -rf {$file}"); |
156 | 156 | } |
157 | 157 | } |
@@ -162,9 +162,9 @@ discard block |
||
162 | 162 | if (file_exists($row['recordingfile']) && !is_dir($row['recordingfile'])) { |
163 | 163 | Util::mwExec("rm -rf {$row['recordingfile']}"); |
164 | 164 | } |
165 | - } elseif ( ! empty($row['recordingfile']) && |
|
166 | - ! file_exists(Util::trimExtensionForFile($row['recordingfile']) . 'wav') && |
|
167 | - ! file_exists( $row['recordingfile']) ) { |
|
165 | + } elseif (!empty($row['recordingfile']) && |
|
166 | + !file_exists(Util::trimExtensionForFile($row['recordingfile']).'wav') && |
|
167 | + !file_exists($row['recordingfile'])) { |
|
168 | 168 | /** @var CallDetailRecordsTmp $rec_data */ |
169 | 169 | $rec_data = CallDetailRecordsTmp::findFirst( |
170 | 170 | "linkedid='{$row['linkedid']}' AND dst_chan='{$row['dst_chan']}'" |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | */ |
214 | 214 | private function getActiveIdChannels(): array |
215 | 215 | { |
216 | - $am = Util::getAstManager('off'); |
|
216 | + $am = Util::getAstManager('off'); |
|
217 | 217 | return $am->GetChannels(true); |
218 | 218 | } |
219 | 219 | |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | $this->no_answered_calls[$row['linkedid']]['NOANSWER'] = false; |
229 | 229 | return; |
230 | 230 | } |
231 | - if ( ! array_key_exists($row['dst_num'], $this->internal_numbers)) { |
|
231 | + if (!array_key_exists($row['dst_num'], $this->internal_numbers)) { |
|
232 | 232 | // dst_num - не является номером сотрудника. Это исходящий. |
233 | 233 | return; |
234 | 234 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function __construct($tube = 'default', $port = '') |
38 | 38 | { |
39 | - $this->tube = str_replace("\\", '-', $tube);; |
|
39 | + $this->tube = str_replace("\\", '-', $tube); ; |
|
40 | 40 | $this->job_options = ['priority' => 250, 'delay' => 0, 'ttr' => 3600]; |
41 | 41 | $this->port = $port; |
42 | 42 | $this->reconnect(); |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | { |
50 | 50 | $config = $this->di->get('config')->beanstalk; |
51 | 51 | $port = $config->port; |
52 | - if(!empty($this->port) && is_numeric($this->port)){ |
|
52 | + if (!empty($this->port) && is_numeric($this->port)) { |
|
53 | 53 | $port = $this->port; |
54 | 54 | } |
55 | 55 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | { |
127 | 127 | $tube = str_replace("\\", '-', $tube); |
128 | 128 | // Change tube |
129 | - if ( ! empty($tube) && $this->tube !== $tube) { |
|
129 | + if (!empty($tube) && $this->tube !== $tube) { |
|
130 | 130 | $this->queue->useTube($tube); |
131 | 131 | } |
132 | 132 | $job_data = serialize($job_data); |
@@ -178,9 +178,9 @@ discard block |
||
178 | 178 | } |
179 | 179 | |
180 | 180 | // Processing job over callable function attached in $this->subscribe |
181 | - if(json_decode($job->getData(), true) !==null){ |
|
182 | - $mData = $job->getData(); |
|
183 | - }else{ |
|
181 | + if (json_decode($job->getData(), true) !== null) { |
|
182 | + $mData = $job->getData(); |
|
183 | + } else { |
|
184 | 184 | $mData = unserialize($job->getData(), [false]); |
185 | 185 | } |
186 | 186 | $this->message = $mData; |
@@ -197,8 +197,8 @@ discard block |
||
197 | 197 | |
198 | 198 | try { |
199 | 199 | $this->queue->delete($job); |
200 | - }catch (\Pheanstalk\Exception\JobNotFoundException $e){ |
|
201 | - }catch (\Error $e){ |
|
200 | + } catch (\Pheanstalk\Exception\JobNotFoundException $e) { |
|
201 | + } catch (\Error $e) { |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | |
@@ -263,28 +263,28 @@ discard block |
||
263 | 263 | /** |
264 | 264 | * Drops orphaned tasks |
265 | 265 | */ |
266 | - public function cleanTube(){ |
|
266 | + public function cleanTube() { |
|
267 | 267 | $tubes = $this->queue->listTubes(); |
268 | - foreach ($tubes as $tube){ |
|
269 | - if(strpos($tube, "INBOX_") !== 0){ |
|
268 | + foreach ($tubes as $tube) { |
|
269 | + if (strpos($tube, "INBOX_") !== 0) { |
|
270 | 270 | continue; |
271 | 271 | } |
272 | 272 | try { |
273 | 273 | $statData = $this->queue->statsTube($tube)->getArrayCopy(); |
274 | 274 | $watching = $statData['current-watching']; |
275 | - if($watching !== '0'){ |
|
275 | + if ($watching !== '0') { |
|
276 | 276 | continue; |
277 | 277 | } |
278 | 278 | // Нужно удалить все Jobs. |
279 | 279 | $this->queue->watch($tube); |
280 | - while (true){ |
|
280 | + while (true) { |
|
281 | 281 | $job = $this->queue->reserveWithTimeout(1); |
282 | - if($job === null){ |
|
282 | + if ($job === null) { |
|
283 | 283 | break; |
284 | 284 | } |
285 | 285 | $this->queue->delete($job); |
286 | 286 | } |
287 | - }catch (\Exception $e){ |
|
287 | + } catch (\Exception $e) { |
|
288 | 288 | continue; |
289 | 289 | } |
290 | 290 |
@@ -83,8 +83,7 @@ discard block |
||
83 | 83 | $job_data, |
84 | 84 | int $timeout = 10, |
85 | 85 | int $priority = PheanstalkInterface::DEFAULT_PRIORITY |
86 | - ) |
|
87 | - { |
|
86 | + ) { |
|
88 | 87 | $this->message = false; |
89 | 88 | $inbox_tube = uniqid('INBOX_', true); |
90 | 89 | $this->queue->watch($inbox_tube); |
@@ -180,7 +179,7 @@ discard block |
||
180 | 179 | // Processing job over callable function attached in $this->subscribe |
181 | 180 | if(json_decode($job->getData(), true) !==null){ |
182 | 181 | $mData = $job->getData(); |
183 | - }else{ |
|
182 | + } else{ |
|
184 | 183 | $mData = unserialize($job->getData(), [false]); |
185 | 184 | } |
186 | 185 | $this->message = $mData; |
@@ -197,8 +196,8 @@ discard block |
||
197 | 196 | |
198 | 197 | try { |
199 | 198 | $this->queue->delete($job); |
200 | - }catch (\Pheanstalk\Exception\JobNotFoundException $e){ |
|
201 | - }catch (\Error $e){ |
|
199 | + } catch (\Pheanstalk\Exception\JobNotFoundException $e){ |
|
200 | + } catch (\Error $e){ |
|
202 | 201 | } |
203 | 202 | } |
204 | 203 | |
@@ -263,7 +262,8 @@ discard block |
||
263 | 262 | /** |
264 | 263 | * Drops orphaned tasks |
265 | 264 | */ |
266 | - public function cleanTube(){ |
|
265 | + public function cleanTube() |
|
266 | + { |
|
267 | 267 | $tubes = $this->queue->listTubes(); |
268 | 268 | foreach ($tubes as $tube){ |
269 | 269 | if(strpos($tube, "INBOX_") !== 0){ |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | } |
285 | 285 | $this->queue->delete($job); |
286 | 286 | } |
287 | - }catch (\Exception $e){ |
|
287 | + } catch (\Exception $e){ |
|
288 | 288 | continue; |
289 | 289 | } |
290 | 290 |