-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathmailer.php
39 lines (29 loc) · 856 Bytes
/
mailer.php
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
#!/usr/bin/env php
<?php
use Phalcon\DI;
use Phalcon\Queue\Beanstalk;
use Phalcon\Queue\Beanstalk\Job;
use Vanchelo\Mailer\MailerService;
// Подключаем конфиг приложения (исправить на свой)
$config = require __DIR__ . '/app/config/config.php';
$di = new DI();
$di->set('config', $config);
$queue = new Beanstalk();
$queue->choose('mailer');
$di['queue'] = $queue;
/**
* Register Mailer Service
*/
$di['mailer'] = function () {
$service = new MailerService();
return $service->mailer();
};
/** @var Job $job */
while (($job = $queue->peekReady()) !== false) {
$data = json_decode($job->getBody(), true);
$segments = explode(':', $data['job']);
if (count($segments) !== 2) {
continue;
}
call_user_func_array([$di[$segments[0]], $segments[1]], [$job, $data['data']]);
}