PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 5.12.1
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v5.12.1
5.12.1 5.12.0 5.11.1 5.11.0 5.10.2 5.10.1 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.3.2 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.1.3 4.10.0 4.11.0 4.12.0 4.13.0 4.13.2 4.13.3 4.13.4 4.13.5 4.14.0 4.14.1 4.14.2 4.15.0 4.15.1 4.15.2 4.15.3 4.2.0 4.3.0 4.3.1 4.4.1 4.4.2 4.5.0 4.6.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.10.0 5.2.0 5.2.1 5.2.2 5.3.0 5.3.1 5.3.2 5.3.3 5.6.0 5.6.1 5.7.0 5.7.1 5.8.0 5.8.1 5.8.2
matomo / app / vendor / prefixed / symfony / monolog-bridge / Handler / SwiftMailerHandler.php
matomo / app / vendor / prefixed / symfony / monolog-bridge / Handler Last commit date
FingersCrossed 1 year ago ChromePhpHandler.php 1 year ago ConsoleHandler.php 1 year ago ElasticsearchLogstashHandler.php 1 year ago FirePHPHandler.php 1 year ago MailerHandler.php 1 year ago NotifierHandler.php 1 year ago ServerLogHandler.php 2 months ago SwiftMailerHandler.php 1 year ago
SwiftMailerHandler.php
84 lines
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11 namespace Matomo\Dependencies\Symfony\Bridge\Monolog\Handler;
12
13 use Matomo\Dependencies\Monolog\Handler\SwiftMailerHandler as BaseSwiftMailerHandler;
14 use Matomo\Dependencies\Symfony\Component\Console\Event\ConsoleTerminateEvent;
15 use Matomo\Dependencies\Symfony\Component\HttpKernel\Event\TerminateEvent;
16 trigger_deprecation('symfony/monolog-bridge', '5.4', '"%s" is deprecated and will be removed in 6.0.', SwiftMailerHandler::class);
17 /**
18 * Extended SwiftMailerHandler that flushes mail queue if necessary.
19 *
20 * @author Philipp Kräutli <pkraeutli@astina.ch>
21 *
22 * @final
23 *
24 * @deprecated since Symfony 5.4
25 */
26 class SwiftMailerHandler extends BaseSwiftMailerHandler
27 {
28 protected $transport;
29 protected $instantFlush = \false;
30 public function setTransport(\Matomo\Dependencies\Swift_Transport $transport)
31 {
32 $this->transport = $transport;
33 }
34 /**
35 * After the kernel has been terminated we will always flush messages.
36 */
37 public function onKernelTerminate(TerminateEvent $event)
38 {
39 $this->instantFlush = \true;
40 }
41 /**
42 * After the CLI application has been terminated we will always flush messages.
43 */
44 public function onCliTerminate(ConsoleTerminateEvent $event)
45 {
46 $this->instantFlush = \true;
47 }
48 /**
49 * {@inheritdoc}
50 */
51 protected function send($content, array $records) : void
52 {
53 parent::send($content, $records);
54 if ($this->instantFlush) {
55 $this->flushMemorySpool();
56 }
57 }
58 /**
59 * {@inheritdoc}
60 */
61 public function reset() : void
62 {
63 $this->flushMemorySpool();
64 }
65 /**
66 * Flushes the mail queue if a memory spool is used.
67 */
68 private function flushMemorySpool()
69 {
70 $mailerTransport = $this->mailer->getTransport();
71 if (!$mailerTransport instanceof \Matomo\Dependencies\Swift_Transport_SpoolTransport) {
72 return;
73 }
74 $spool = $mailerTransport->getSpool();
75 if (!$spool instanceof \Matomo\Dependencies\Swift_MemorySpool) {
76 return;
77 }
78 if (null === $this->transport) {
79 throw new \Exception('No transport available to flush mail queue.');
80 }
81 $spool->flushQueue($this->transport);
82 }
83 }
84