forked from friendica/friendica-addons
[monolog] Update Composer dependencies ahead of release
- Updating monolog/monolog (2.9.1 => 2.9.2)
This commit is contained in:
parent
d838fc6421
commit
a020ac4309
|
@ -1,23 +1,26 @@
|
||||||
{
|
{
|
||||||
"name": "friendica-addons/monolog",
|
"name": "friendica-addons/monolog",
|
||||||
"description": "Monolog can send your logs to files, sockets, inboxes, database, etc..",
|
"description": "Monolog can send your logs to files, sockets, inboxes, database, etc..",
|
||||||
"type": "friendica-addon",
|
"type": "friendica-addon",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "Philipp Holzer",
|
"name": "Philipp Holzer",
|
||||||
"email": "admin@philipp.info",
|
"email": "admin@philipp.info",
|
||||||
"homepage": "https://blog.philipp.info",
|
"homepage": "https://blog.philipp.info",
|
||||||
"role": "Developer"
|
"role": "Developer"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.3",
|
"php": ">=7.3",
|
||||||
"monolog/monolog": "^2.9"
|
"monolog/monolog": "^2.9"
|
||||||
},
|
},
|
||||||
"license": "3-clause BSD license",
|
"license": "3-clause BSD license",
|
||||||
"config": {
|
"config": {
|
||||||
"optimize-autoloader": true,
|
"platform": {
|
||||||
"autoloader-suffix": "MonologAddon",
|
"php": "7.4"
|
||||||
"preferred-install": "dist"
|
},
|
||||||
}
|
"optimize-autoloader": true,
|
||||||
|
"autoloader-suffix": "MonologAddon",
|
||||||
|
"preferred-install": "dist"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
15
monolog/composer.lock
generated
15
monolog/composer.lock
generated
|
@ -4,20 +4,20 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "6fd294bd163b37ac6cc400e0f8785222",
|
"content-hash": "037f2db47e77c9af2960dde65ebafa8d",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "monolog/monolog",
|
"name": "monolog/monolog",
|
||||||
"version": "2.9.1",
|
"version": "2.9.2",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/Seldaek/monolog.git",
|
"url": "https://github.com/Seldaek/monolog.git",
|
||||||
"reference": "f259e2b15fb95494c83f52d3caad003bbf5ffaa1"
|
"reference": "437cb3628f4cf6042cc10ae97fc2b8472e48ca1f"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/f259e2b15fb95494c83f52d3caad003bbf5ffaa1",
|
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/437cb3628f4cf6042cc10ae97fc2b8472e48ca1f",
|
||||||
"reference": "f259e2b15fb95494c83f52d3caad003bbf5ffaa1",
|
"reference": "437cb3628f4cf6042cc10ae97fc2b8472e48ca1f",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -102,7 +102,7 @@
|
||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2023-02-06T13:44:46+00:00"
|
"time": "2023-10-27T15:25:26+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "psr/log",
|
"name": "psr/log",
|
||||||
|
@ -162,5 +162,8 @@
|
||||||
"php": ">=7.3"
|
"php": ">=7.3"
|
||||||
},
|
},
|
||||||
"platform-dev": [],
|
"platform-dev": [],
|
||||||
|
"platform-overrides": {
|
||||||
|
"php": "7.4"
|
||||||
|
},
|
||||||
"plugin-api-version": "1.1.0"
|
"plugin-api-version": "1.1.0"
|
||||||
}
|
}
|
||||||
|
|
11
monolog/vendor/composer/autoload_classmap.php
vendored
11
monolog/vendor/composer/autoload_classmap.php
vendored
|
@ -121,15 +121,4 @@ return array(
|
||||||
'Monolog\\SignalHandler' => $vendorDir . '/monolog/monolog/src/Monolog/SignalHandler.php',
|
'Monolog\\SignalHandler' => $vendorDir . '/monolog/monolog/src/Monolog/SignalHandler.php',
|
||||||
'Monolog\\Test\\TestCase' => $vendorDir . '/monolog/monolog/src/Monolog/Test/TestCase.php',
|
'Monolog\\Test\\TestCase' => $vendorDir . '/monolog/monolog/src/Monolog/Test/TestCase.php',
|
||||||
'Monolog\\Utils' => $vendorDir . '/monolog/monolog/src/Monolog/Utils.php',
|
'Monolog\\Utils' => $vendorDir . '/monolog/monolog/src/Monolog/Utils.php',
|
||||||
'Psr\\Log\\AbstractLogger' => $vendorDir . '/psr/log/Psr/Log/AbstractLogger.php',
|
|
||||||
'Psr\\Log\\InvalidArgumentException' => $vendorDir . '/psr/log/Psr/Log/InvalidArgumentException.php',
|
|
||||||
'Psr\\Log\\LogLevel' => $vendorDir . '/psr/log/Psr/Log/LogLevel.php',
|
|
||||||
'Psr\\Log\\LoggerAwareInterface' => $vendorDir . '/psr/log/Psr/Log/LoggerAwareInterface.php',
|
|
||||||
'Psr\\Log\\LoggerAwareTrait' => $vendorDir . '/psr/log/Psr/Log/LoggerAwareTrait.php',
|
|
||||||
'Psr\\Log\\LoggerInterface' => $vendorDir . '/psr/log/Psr/Log/LoggerInterface.php',
|
|
||||||
'Psr\\Log\\LoggerTrait' => $vendorDir . '/psr/log/Psr/Log/LoggerTrait.php',
|
|
||||||
'Psr\\Log\\NullLogger' => $vendorDir . '/psr/log/Psr/Log/NullLogger.php',
|
|
||||||
'Psr\\Log\\Test\\DummyTest' => $vendorDir . '/psr/log/Psr/Log/Test/DummyTest.php',
|
|
||||||
'Psr\\Log\\Test\\LoggerInterfaceTest' => $vendorDir . '/psr/log/Psr/Log/Test/LoggerInterfaceTest.php',
|
|
||||||
'Psr\\Log\\Test\\TestLogger' => $vendorDir . '/psr/log/Psr/Log/Test/TestLogger.php',
|
|
||||||
);
|
);
|
||||||
|
|
11
monolog/vendor/composer/autoload_static.php
vendored
11
monolog/vendor/composer/autoload_static.php
vendored
|
@ -144,17 +144,6 @@ class ComposerStaticInitMonologAddon
|
||||||
'Monolog\\SignalHandler' => __DIR__ . '/..' . '/monolog/monolog/src/Monolog/SignalHandler.php',
|
'Monolog\\SignalHandler' => __DIR__ . '/..' . '/monolog/monolog/src/Monolog/SignalHandler.php',
|
||||||
'Monolog\\Test\\TestCase' => __DIR__ . '/..' . '/monolog/monolog/src/Monolog/Test/TestCase.php',
|
'Monolog\\Test\\TestCase' => __DIR__ . '/..' . '/monolog/monolog/src/Monolog/Test/TestCase.php',
|
||||||
'Monolog\\Utils' => __DIR__ . '/..' . '/monolog/monolog/src/Monolog/Utils.php',
|
'Monolog\\Utils' => __DIR__ . '/..' . '/monolog/monolog/src/Monolog/Utils.php',
|
||||||
'Psr\\Log\\AbstractLogger' => __DIR__ . '/..' . '/psr/log/Psr/Log/AbstractLogger.php',
|
|
||||||
'Psr\\Log\\InvalidArgumentException' => __DIR__ . '/..' . '/psr/log/Psr/Log/InvalidArgumentException.php',
|
|
||||||
'Psr\\Log\\LogLevel' => __DIR__ . '/..' . '/psr/log/Psr/Log/LogLevel.php',
|
|
||||||
'Psr\\Log\\LoggerAwareInterface' => __DIR__ . '/..' . '/psr/log/Psr/Log/LoggerAwareInterface.php',
|
|
||||||
'Psr\\Log\\LoggerAwareTrait' => __DIR__ . '/..' . '/psr/log/Psr/Log/LoggerAwareTrait.php',
|
|
||||||
'Psr\\Log\\LoggerInterface' => __DIR__ . '/..' . '/psr/log/Psr/Log/LoggerInterface.php',
|
|
||||||
'Psr\\Log\\LoggerTrait' => __DIR__ . '/..' . '/psr/log/Psr/Log/LoggerTrait.php',
|
|
||||||
'Psr\\Log\\NullLogger' => __DIR__ . '/..' . '/psr/log/Psr/Log/NullLogger.php',
|
|
||||||
'Psr\\Log\\Test\\DummyTest' => __DIR__ . '/..' . '/psr/log/Psr/Log/Test/DummyTest.php',
|
|
||||||
'Psr\\Log\\Test\\LoggerInterfaceTest' => __DIR__ . '/..' . '/psr/log/Psr/Log/Test/LoggerInterfaceTest.php',
|
|
||||||
'Psr\\Log\\Test\\TestLogger' => __DIR__ . '/..' . '/psr/log/Psr/Log/Test/TestLogger.php',
|
|
||||||
);
|
);
|
||||||
|
|
||||||
public static function getInitializer(ClassLoader $loader)
|
public static function getInitializer(ClassLoader $loader)
|
||||||
|
|
12
monolog/vendor/composer/installed.json
vendored
12
monolog/vendor/composer/installed.json
vendored
|
@ -1,17 +1,17 @@
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": "monolog/monolog",
|
"name": "monolog/monolog",
|
||||||
"version": "2.9.1",
|
"version": "2.9.2",
|
||||||
"version_normalized": "2.9.1.0",
|
"version_normalized": "2.9.2.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/Seldaek/monolog.git",
|
"url": "https://github.com/Seldaek/monolog.git",
|
||||||
"reference": "f259e2b15fb95494c83f52d3caad003bbf5ffaa1"
|
"reference": "437cb3628f4cf6042cc10ae97fc2b8472e48ca1f"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/f259e2b15fb95494c83f52d3caad003bbf5ffaa1",
|
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/437cb3628f4cf6042cc10ae97fc2b8472e48ca1f",
|
||||||
"reference": "f259e2b15fb95494c83f52d3caad003bbf5ffaa1",
|
"reference": "437cb3628f4cf6042cc10ae97fc2b8472e48ca1f",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -57,7 +57,7 @@
|
||||||
"rollbar/rollbar": "Allow sending log messages to Rollbar",
|
"rollbar/rollbar": "Allow sending log messages to Rollbar",
|
||||||
"ruflin/elastica": "Allow sending log messages to an Elastic Search server"
|
"ruflin/elastica": "Allow sending log messages to an Elastic Search server"
|
||||||
},
|
},
|
||||||
"time": "2023-02-06T13:44:46+00:00",
|
"time": "2023-10-27T15:25:26+00:00",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
|
|
6
monolog/vendor/monolog/monolog/CHANGELOG.md
vendored
6
monolog/vendor/monolog/monolog/CHANGELOG.md
vendored
|
@ -1,3 +1,9 @@
|
||||||
|
### 2.9.2 (2023-10-27)
|
||||||
|
|
||||||
|
* Fixed display_errors parsing in ErrorHandler which did not support string values (#1804)
|
||||||
|
* Fixed bug where the previous error handler would not be restored in some cases where StreamHandler fails (#1815)
|
||||||
|
* Fixed normalization error when normalizing incomplete classes (#1833)
|
||||||
|
|
||||||
### 2.9.1 (2023-02-06)
|
### 2.9.1 (2023-02-06)
|
||||||
|
|
||||||
* Fixed Logger not being serializable anymore (#1792)
|
* Fixed Logger not being serializable anymore (#1792)
|
||||||
|
|
72
monolog/vendor/monolog/monolog/UPGRADE.md
vendored
Normal file
72
monolog/vendor/monolog/monolog/UPGRADE.md
vendored
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
### 2.0.0
|
||||||
|
|
||||||
|
- `Monolog\Logger::API` can be used to distinguish between a Monolog `1` and `2`
|
||||||
|
install of Monolog when writing integration code.
|
||||||
|
|
||||||
|
- Removed non-PSR-3 methods to add records, all the `add*` (e.g. `addWarning`)
|
||||||
|
methods as well as `emerg`, `crit`, `err` and `warn`.
|
||||||
|
|
||||||
|
- DateTime are now formatted with a timezone and microseconds (unless disabled).
|
||||||
|
Various formatters and log output might be affected, which may mess with log parsing
|
||||||
|
in some cases.
|
||||||
|
|
||||||
|
- The `datetime` in every record array is now a DateTimeImmutable, not that you
|
||||||
|
should have been modifying these anyway.
|
||||||
|
|
||||||
|
- The timezone is now set per Logger instance and not statically, either
|
||||||
|
via ->setTimezone or passed in the constructor. Calls to Logger::setTimezone
|
||||||
|
should be converted.
|
||||||
|
|
||||||
|
- `HandlerInterface` has been split off and two new interfaces now exist for
|
||||||
|
more granular controls: `ProcessableHandlerInterface` and
|
||||||
|
`FormattableHandlerInterface`. Handlers not extending `AbstractHandler`
|
||||||
|
should make sure to implement the relevant interfaces.
|
||||||
|
|
||||||
|
- `HandlerInterface` now requires the `close` method to be implemented. This
|
||||||
|
only impacts you if you implement the interface yourself, but you can extend
|
||||||
|
the new `Monolog\Handler\Handler` base class too.
|
||||||
|
|
||||||
|
- There is no more default handler configured on empty Logger instances, if
|
||||||
|
you were relying on that you will not get any output anymore, make sure to
|
||||||
|
configure the handler you need.
|
||||||
|
|
||||||
|
#### LogglyFormatter
|
||||||
|
|
||||||
|
- The records' `datetime` is not sent anymore. Only `timestamp` is sent to Loggly.
|
||||||
|
|
||||||
|
#### AmqpHandler
|
||||||
|
|
||||||
|
- Log levels are not shortened to 4 characters anymore. e.g. a warning record
|
||||||
|
will be sent using the `warning.channel` routing key instead of `warn.channel`
|
||||||
|
as in 1.x.
|
||||||
|
- The exchange name does not default to 'log' anymore, and it is completely ignored
|
||||||
|
now for the AMQP extension users. Only PHPAmqpLib uses it if provided.
|
||||||
|
|
||||||
|
#### RotatingFileHandler
|
||||||
|
|
||||||
|
- The file name format must now contain `{date}` and the date format must be set
|
||||||
|
to one of the predefined FILE_PER_* constants to avoid issues with file rotation.
|
||||||
|
See `setFilenameFormat`.
|
||||||
|
|
||||||
|
#### LogstashFormatter
|
||||||
|
|
||||||
|
- Removed Logstash V0 support
|
||||||
|
- Context/extra prefix has been removed in favor of letting users configure the exact key being sent
|
||||||
|
- Context/extra data are now sent as an object instead of single keys
|
||||||
|
|
||||||
|
#### HipChatHandler
|
||||||
|
|
||||||
|
- Removed deprecated HipChat handler, migrate to Slack and use SlackWebhookHandler or SlackHandler instead
|
||||||
|
|
||||||
|
#### SlackbotHandler
|
||||||
|
|
||||||
|
- Removed deprecated SlackbotHandler handler, use SlackWebhookHandler or SlackHandler instead
|
||||||
|
|
||||||
|
#### RavenHandler
|
||||||
|
|
||||||
|
- Removed deprecated RavenHandler handler, use sentry/sentry 2.x and their Sentry\Monolog\Handler instead
|
||||||
|
|
||||||
|
#### ElasticSearchHandler
|
||||||
|
|
||||||
|
- As support for the official Elasticsearch library was added, the former ElasticSearchHandler has been
|
||||||
|
renamed to ElasticaHandler and the new one added as ElasticsearchHandler.
|
|
@ -198,7 +198,7 @@ class ErrorHandler
|
||||||
($this->previousExceptionHandler)($e);
|
($this->previousExceptionHandler)($e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!headers_sent() && !ini_get('display_errors')) {
|
if (!headers_sent() && in_array(strtolower((string) ini_get('display_errors')), ['0', '', 'false', 'off', 'none', 'no'], true)) {
|
||||||
http_response_code(500);
|
http_response_code(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -155,7 +155,7 @@ class LineFormatter extends NormalizerFormatter
|
||||||
do {
|
do {
|
||||||
$depth++;
|
$depth++;
|
||||||
if ($depth > $this->maxNormalizeDepth) {
|
if ($depth > $this->maxNormalizeDepth) {
|
||||||
$str .= '\n[previous exception] Over ' . $this->maxNormalizeDepth . ' levels deep, aborting normalization';
|
$str .= "\n[previous exception] Over " . $this->maxNormalizeDepth . ' levels deep, aborting normalization';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -174,6 +174,9 @@ class NormalizerFormatter implements FormatterInterface
|
||||||
if ($data instanceof \JsonSerializable) {
|
if ($data instanceof \JsonSerializable) {
|
||||||
/** @var null|scalar|array<array|scalar|null> $value */
|
/** @var null|scalar|array<array|scalar|null> $value */
|
||||||
$value = $data->jsonSerialize();
|
$value = $data->jsonSerialize();
|
||||||
|
} elseif (\get_class($data) === '__PHP_Incomplete_Class') {
|
||||||
|
$accessor = new \ArrayObject($data);
|
||||||
|
$value = (string) $accessor['__PHP_Incomplete_Class_Name'];
|
||||||
} elseif (method_exists($data, '__toString')) {
|
} elseif (method_exists($data, '__toString')) {
|
||||||
/** @var string $value */
|
/** @var string $value */
|
||||||
$value = $data->__toString();
|
$value = $data->__toString();
|
||||||
|
|
|
@ -135,11 +135,14 @@ class StreamHandler extends AbstractProcessingHandler
|
||||||
$this->createDir($url);
|
$this->createDir($url);
|
||||||
$this->errorMessage = null;
|
$this->errorMessage = null;
|
||||||
set_error_handler([$this, 'customErrorHandler']);
|
set_error_handler([$this, 'customErrorHandler']);
|
||||||
$stream = fopen($url, 'a');
|
try {
|
||||||
if ($this->filePermission !== null) {
|
$stream = fopen($url, 'a');
|
||||||
@chmod($url, $this->filePermission);
|
if ($this->filePermission !== null) {
|
||||||
|
@chmod($url, $this->filePermission);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
restore_error_handler();
|
||||||
}
|
}
|
||||||
restore_error_handler();
|
|
||||||
if (!is_resource($stream)) {
|
if (!is_resource($stream)) {
|
||||||
$this->stream = null;
|
$this->stream = null;
|
||||||
|
|
||||||
|
|
115
monolog/vendor/monolog/monolog/src/Monolog/Handler/SwiftMailerHandler.php
vendored
Normal file
115
monolog/vendor/monolog/monolog/src/Monolog/Handler/SwiftMailerHandler.php
vendored
Normal file
|
@ -0,0 +1,115 @@
|
||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Monolog package.
|
||||||
|
*
|
||||||
|
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Monolog\Handler;
|
||||||
|
|
||||||
|
use Monolog\Logger;
|
||||||
|
use Monolog\Utils;
|
||||||
|
use Monolog\Formatter\FormatterInterface;
|
||||||
|
use Monolog\Formatter\LineFormatter;
|
||||||
|
use Swift_Message;
|
||||||
|
use Swift;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SwiftMailerHandler uses Swift_Mailer to send the emails
|
||||||
|
*
|
||||||
|
* @author Gyula Sallai
|
||||||
|
*
|
||||||
|
* @phpstan-import-type Record from \Monolog\Logger
|
||||||
|
* @deprecated Since Monolog 2.6. Use SymfonyMailerHandler instead.
|
||||||
|
*/
|
||||||
|
class SwiftMailerHandler extends MailHandler
|
||||||
|
{
|
||||||
|
/** @var \Swift_Mailer */
|
||||||
|
protected $mailer;
|
||||||
|
/** @var Swift_Message|callable(string, Record[]): Swift_Message */
|
||||||
|
private $messageTemplate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @psalm-param Swift_Message|callable(string, Record[]): Swift_Message $message
|
||||||
|
*
|
||||||
|
* @param \Swift_Mailer $mailer The mailer to use
|
||||||
|
* @param callable|Swift_Message $message An example message for real messages, only the body will be replaced
|
||||||
|
*/
|
||||||
|
public function __construct(\Swift_Mailer $mailer, $message, $level = Logger::ERROR, bool $bubble = true)
|
||||||
|
{
|
||||||
|
parent::__construct($level, $bubble);
|
||||||
|
|
||||||
|
@trigger_error('The SwiftMailerHandler is deprecated since Monolog 2.6. Use SymfonyMailerHandler instead.', E_USER_DEPRECATED);
|
||||||
|
|
||||||
|
$this->mailer = $mailer;
|
||||||
|
$this->messageTemplate = $message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
protected function send(string $content, array $records): void
|
||||||
|
{
|
||||||
|
$this->mailer->send($this->buildMessage($content, $records));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the formatter for the Swift_Message subject.
|
||||||
|
*
|
||||||
|
* @param string|null $format The format of the subject
|
||||||
|
*/
|
||||||
|
protected function getSubjectFormatter(?string $format): FormatterInterface
|
||||||
|
{
|
||||||
|
return new LineFormatter($format);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates instance of Swift_Message to be sent
|
||||||
|
*
|
||||||
|
* @param string $content formatted email body to be sent
|
||||||
|
* @param array $records Log records that formed the content
|
||||||
|
* @return Swift_Message
|
||||||
|
*
|
||||||
|
* @phpstan-param Record[] $records
|
||||||
|
*/
|
||||||
|
protected function buildMessage(string $content, array $records): Swift_Message
|
||||||
|
{
|
||||||
|
$message = null;
|
||||||
|
if ($this->messageTemplate instanceof Swift_Message) {
|
||||||
|
$message = clone $this->messageTemplate;
|
||||||
|
$message->generateId();
|
||||||
|
} elseif (is_callable($this->messageTemplate)) {
|
||||||
|
$message = ($this->messageTemplate)($content, $records);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$message instanceof Swift_Message) {
|
||||||
|
$record = reset($records);
|
||||||
|
throw new \InvalidArgumentException('Could not resolve message as instance of Swift_Message or a callable returning it' . ($record ? Utils::getRecordMessageForException($record) : ''));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($records) {
|
||||||
|
$subjectFormatter = $this->getSubjectFormatter($message->getSubject());
|
||||||
|
$message->setSubject($subjectFormatter->format($this->getHighestRecord($records)));
|
||||||
|
}
|
||||||
|
|
||||||
|
$mime = 'text/plain';
|
||||||
|
if ($this->isHtmlBody($content)) {
|
||||||
|
$mime = 'text/html';
|
||||||
|
}
|
||||||
|
|
||||||
|
$message->setBody($content, $mime);
|
||||||
|
/** @phpstan-ignore-next-line */
|
||||||
|
if (version_compare(Swift::VERSION, '6.0.0', '>=')) {
|
||||||
|
$message->setDate(new \DateTimeImmutable());
|
||||||
|
} else {
|
||||||
|
/** @phpstan-ignore-next-line */
|
||||||
|
$message->setDate(time());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $message;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue