|
0
|
1 |
<?php |
|
|
2 |
|
|
|
3 |
/* |
|
|
4 |
* This file is part of the Monolog package. |
|
|
5 |
* |
|
|
6 |
* (c) Jordi Boggiano <j.boggiano@seld.be> |
|
|
7 |
* |
|
|
8 |
* For the full copyright and license information, please view the LICENSE |
|
|
9 |
* file that was distributed with this source code. |
|
|
10 |
*/ |
|
|
11 |
|
|
|
12 |
namespace Monolog\Handler; |
|
|
13 |
|
|
|
14 |
/** |
|
|
15 |
* Base class for all mail handlers |
|
|
16 |
* |
|
|
17 |
* @author Gyula Sallai |
|
|
18 |
*/ |
|
|
19 |
abstract class MailHandler extends AbstractProcessingHandler |
|
|
20 |
{ |
|
|
21 |
/** |
|
|
22 |
* {@inheritdoc} |
|
|
23 |
*/ |
|
|
24 |
public function handleBatch(array $records) |
|
|
25 |
{ |
|
|
26 |
$messages = array(); |
|
|
27 |
|
|
|
28 |
foreach ($records as $record) { |
|
|
29 |
if ($record['level'] < $this->level) { |
|
|
30 |
continue; |
|
|
31 |
} |
|
|
32 |
$messages[] = $this->processRecord($record); |
|
|
33 |
} |
|
|
34 |
|
|
|
35 |
if (!empty($messages)) { |
|
|
36 |
$this->send((string) $this->getFormatter()->formatBatch($messages)); |
|
|
37 |
} |
|
|
38 |
} |
|
|
39 |
|
|
|
40 |
/** |
|
|
41 |
* Send a mail with the given content |
|
|
42 |
* |
|
|
43 |
* @param string $content |
|
|
44 |
*/ |
|
|
45 |
abstract protected function send($content); |
|
|
46 |
|
|
|
47 |
/** |
|
|
48 |
* {@inheritdoc} |
|
|
49 |
*/ |
|
|
50 |
protected function write(array $record) |
|
|
51 |
{ |
|
|
52 |
$this->send((string) $record['formatted']); |
|
|
53 |
} |
|
|
54 |
} |