Stand: SMTP-Test, Admin-Mail-Tab, Notifiable-Fix, Lazy-Quill
- Fix: Notifiable-Trait zum User-Model hinzugefuegt (behebt notify()-500er) - Installer: SMTP-Verbindungstest mit EsmtpTransport + Ueberspringen-Link - Admin: Neuer E-Mail-Tab mit SMTP-Konfiguration + Verbindungstest - Admin: Lazy Quill-Initialisierung (nur sichtbare Locale wird geladen) - Uebersetzungen: 17 neue Mail-Keys in allen 6 Sprachen Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
95
vendor/symfony/mime/Part/AbstractMultipartPart.php
vendored
Executable file
95
vendor/symfony/mime/Part/AbstractMultipartPart.php
vendored
Executable file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Mime\Part;
|
||||
|
||||
use Symfony\Component\Mime\Header\Headers;
|
||||
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
abstract class AbstractMultipartPart extends AbstractPart
|
||||
{
|
||||
private ?string $boundary = null;
|
||||
private array $parts = [];
|
||||
|
||||
public function __construct(AbstractPart ...$parts)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
foreach ($parts as $part) {
|
||||
$this->parts[] = $part;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AbstractPart[]
|
||||
*/
|
||||
public function getParts(): array
|
||||
{
|
||||
return $this->parts;
|
||||
}
|
||||
|
||||
public function getMediaType(): string
|
||||
{
|
||||
return 'multipart';
|
||||
}
|
||||
|
||||
public function getPreparedHeaders(): Headers
|
||||
{
|
||||
$headers = parent::getPreparedHeaders();
|
||||
$headers->setHeaderParameter('Content-Type', 'boundary', $this->getBoundary());
|
||||
|
||||
return $headers;
|
||||
}
|
||||
|
||||
public function bodyToString(): string
|
||||
{
|
||||
$parts = $this->getParts();
|
||||
$string = '';
|
||||
foreach ($parts as $part) {
|
||||
$string .= '--'.$this->getBoundary()."\r\n".$part->toString()."\r\n";
|
||||
}
|
||||
$string .= '--'.$this->getBoundary()."--\r\n";
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public function bodyToIterable(): iterable
|
||||
{
|
||||
$parts = $this->getParts();
|
||||
foreach ($parts as $part) {
|
||||
yield '--'.$this->getBoundary()."\r\n";
|
||||
yield from $part->toIterable();
|
||||
yield "\r\n";
|
||||
}
|
||||
yield '--'.$this->getBoundary()."--\r\n";
|
||||
}
|
||||
|
||||
public function asDebugString(): string
|
||||
{
|
||||
$str = parent::asDebugString();
|
||||
foreach ($this->getParts() as $part) {
|
||||
$lines = explode("\n", $part->asDebugString());
|
||||
$str .= "\n └ ".array_shift($lines);
|
||||
foreach ($lines as $line) {
|
||||
$str .= "\n |".$line;
|
||||
}
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
private function getBoundary(): string
|
||||
{
|
||||
return $this->boundary ??= strtr(base64_encode(random_bytes(6)), '+/', '-_');
|
||||
}
|
||||
}
|
||||
116
vendor/symfony/mime/Part/AbstractPart.php
vendored
Executable file
116
vendor/symfony/mime/Part/AbstractPart.php
vendored
Executable file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Mime\Part;
|
||||
|
||||
use Symfony\Component\Mime\Header\Headers;
|
||||
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
abstract class AbstractPart
|
||||
{
|
||||
private Headers $headers;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->headers = new Headers();
|
||||
}
|
||||
|
||||
public function getHeaders(): Headers
|
||||
{
|
||||
return $this->headers;
|
||||
}
|
||||
|
||||
public function getPreparedHeaders(): Headers
|
||||
{
|
||||
$headers = clone $this->headers;
|
||||
$headers->setHeaderBody('Parameterized', 'Content-Type', $this->getMediaType().'/'.$this->getMediaSubtype());
|
||||
|
||||
return $headers;
|
||||
}
|
||||
|
||||
public function toString(): string
|
||||
{
|
||||
return $this->getPreparedHeaders()->toString()."\r\n".$this->bodyToString();
|
||||
}
|
||||
|
||||
public function toIterable(): iterable
|
||||
{
|
||||
yield $this->getPreparedHeaders()->toString();
|
||||
yield "\r\n";
|
||||
yield from $this->bodyToIterable();
|
||||
}
|
||||
|
||||
public function asDebugString(): string
|
||||
{
|
||||
return $this->getMediaType().'/'.$this->getMediaSubtype();
|
||||
}
|
||||
|
||||
abstract public function bodyToString(): string;
|
||||
|
||||
abstract public function bodyToIterable(): iterable;
|
||||
|
||||
abstract public function getMediaType(): string;
|
||||
|
||||
abstract public function getMediaSubtype(): string;
|
||||
|
||||
public function __serialize(): array
|
||||
{
|
||||
if (!method_exists($this, '__sleep')) {
|
||||
return ['headers' => $this->headers];
|
||||
}
|
||||
|
||||
trigger_deprecation('symfony/mime', '7.4', 'Implementing "%s::__sleep()" is deprecated, use "__serialize()" instead.', get_debug_type($this));
|
||||
|
||||
$data = [];
|
||||
foreach ($this->__sleep() as $key) {
|
||||
try {
|
||||
if (($r = new \ReflectionProperty($this, $key))->isInitialized($this)) {
|
||||
$data[$key] = $r->getValue($this);
|
||||
}
|
||||
} catch (\ReflectionException) {
|
||||
$data[$key] = $this->$key;
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function __unserialize(array $data): void
|
||||
{
|
||||
if ($wakeup = method_exists($this, '__wakeup') && self::class === (new \ReflectionMethod($this, '__unserialize'))->class) {
|
||||
trigger_deprecation('symfony/mime', '7.4', 'Implementing "%s::__wakeup()" is deprecated, use "__unserialize()" instead.', get_debug_type($this));
|
||||
}
|
||||
|
||||
if (['headers'] === array_keys($data)) {
|
||||
$this->headers = $data['headers'];
|
||||
|
||||
if ($wakeup) {
|
||||
$this->__wakeup();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
trigger_deprecation('symfony/mime', '7.4', 'Passing more than just key "headers" to "%s::__unserialize()" is deprecated, populate properties in "%s::__unserialize()" instead.', self::class, get_debug_type($this));
|
||||
|
||||
\Closure::bind(function ($data) use ($wakeup) {
|
||||
foreach ($data as $key => $value) {
|
||||
$this->{("\0" === $key[0] ?? '') ? substr($key, 1 + strrpos($key, "\0")) : $key} = $value;
|
||||
}
|
||||
|
||||
if ($wakeup) {
|
||||
$this->__wakeup();
|
||||
}
|
||||
}, $this, static::class)($data);
|
||||
}
|
||||
}
|
||||
246
vendor/symfony/mime/Part/DataPart.php
vendored
Executable file
246
vendor/symfony/mime/Part/DataPart.php
vendored
Executable file
@@ -0,0 +1,246 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Mime\Part;
|
||||
|
||||
use Symfony\Component\Mime\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Mime\Header\Headers;
|
||||
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class DataPart extends TextPart
|
||||
{
|
||||
/** @internal, to be removed in 8.0 */
|
||||
protected array $_parent;
|
||||
|
||||
private ?string $filename = null;
|
||||
private string $mediaType;
|
||||
private ?string $cid = null;
|
||||
|
||||
/**
|
||||
* @param resource|string|File $body Use a File instance to defer loading the file until rendering
|
||||
*/
|
||||
public function __construct($body, ?string $filename = null, ?string $contentType = null, ?string $encoding = null)
|
||||
{
|
||||
if ($body instanceof File && !$filename) {
|
||||
$filename = $body->getFilename();
|
||||
}
|
||||
|
||||
$contentType ??= $body instanceof File ? $body->getContentType() : 'application/octet-stream';
|
||||
[$this->mediaType, $subtype] = explode('/', $contentType);
|
||||
|
||||
parent::__construct($body, null, $subtype, $encoding);
|
||||
|
||||
if (null !== $filename) {
|
||||
$this->filename = $filename;
|
||||
$this->setName($filename);
|
||||
}
|
||||
$this->setDisposition('attachment');
|
||||
}
|
||||
|
||||
public static function fromPath(string $path, ?string $name = null, ?string $contentType = null): self
|
||||
{
|
||||
return new self(new File($path), $name, $contentType);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function asInline(): static
|
||||
{
|
||||
return $this->setDisposition('inline');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setContentId(string $cid): static
|
||||
{
|
||||
if (!str_contains($cid, '@')) {
|
||||
throw new InvalidArgumentException(\sprintf('The "%s" CID is invalid as it doesn\'t contain an "@".', $cid));
|
||||
}
|
||||
|
||||
$this->cid = $cid;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getContentId(): string
|
||||
{
|
||||
return $this->cid ?: $this->cid = $this->generateContentId();
|
||||
}
|
||||
|
||||
public function hasContentId(): bool
|
||||
{
|
||||
return null !== $this->cid;
|
||||
}
|
||||
|
||||
public function getMediaType(): string
|
||||
{
|
||||
return $this->mediaType;
|
||||
}
|
||||
|
||||
public function getPreparedHeaders(): Headers
|
||||
{
|
||||
$headers = parent::getPreparedHeaders();
|
||||
|
||||
if (null !== $this->cid) {
|
||||
$headers->setHeaderBody('Id', 'Content-ID', $this->cid);
|
||||
}
|
||||
|
||||
if (null !== $this->filename) {
|
||||
$headers->setHeaderParameter('Content-Disposition', 'filename', $this->filename);
|
||||
}
|
||||
|
||||
return $headers;
|
||||
}
|
||||
|
||||
public function asDebugString(): string
|
||||
{
|
||||
$str = parent::asDebugString();
|
||||
if (null !== $this->filename) {
|
||||
$str .= ' filename: '.$this->filename;
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function getFilename(): ?string
|
||||
{
|
||||
return $this->filename;
|
||||
}
|
||||
|
||||
public function getContentType(): string
|
||||
{
|
||||
return implode('/', [$this->getMediaType(), $this->getMediaSubtype()]);
|
||||
}
|
||||
|
||||
private function generateContentId(): string
|
||||
{
|
||||
return bin2hex(random_bytes(16)).'@symfony';
|
||||
}
|
||||
|
||||
public function __serialize(): array
|
||||
{
|
||||
if (self::class === (new \ReflectionMethod($this, '__sleep'))->class || self::class !== (new \ReflectionMethod($this, '__serialize'))->class) {
|
||||
$parent = parent::__serialize();
|
||||
$headers = $parent['_headers'];
|
||||
unset($parent['_headers']);
|
||||
|
||||
return [
|
||||
'_headers' => $headers,
|
||||
'_parent' => $parent,
|
||||
'filename' => $this->filename,
|
||||
'mediaType' => $this->mediaType,
|
||||
];
|
||||
}
|
||||
|
||||
trigger_deprecation('symfony/mime', '7.4', 'Implementing "%s::__sleep()" is deprecated, use "__serialize()" instead.', get_debug_type($this));
|
||||
|
||||
$data = [];
|
||||
foreach ($this->__sleep() as $key) {
|
||||
try {
|
||||
if (($r = new \ReflectionProperty($this, $key))->isInitialized($this)) {
|
||||
$data[$key] = $r->getValue($this);
|
||||
}
|
||||
} catch (\ReflectionException) {
|
||||
$data[$key] = $this->$key;
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function __unserialize(array $data): void
|
||||
{
|
||||
if ($wakeup = self::class !== (new \ReflectionMethod($this, '__wakeup'))->class && self::class === (new \ReflectionMethod($this, '__unserialize'))->class) {
|
||||
trigger_deprecation('symfony/mime', '7.4', 'Implementing "%s::__wakeup()" is deprecated, use "__unserialize()" instead.', get_debug_type($this));
|
||||
}
|
||||
|
||||
if (['_headers', '_parent', 'filename', 'mediaType'] === array_keys($data)) {
|
||||
parent::__unserialize(['_headers' => $data['_headers'], ...$data['_parent']]);
|
||||
$this->filename = $data['filename'];
|
||||
$this->mediaType = $data['mediaType'];
|
||||
|
||||
if ($wakeup) {
|
||||
$this->__wakeup();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (["\0*\0_headers", "\0*\0_parent", "\0".self::class."\0filename", "\0".self::class."\0mediaType"] === array_keys($data)) {
|
||||
parent::__unserialize(['_headers' => $data["\0*\0_headers"], ...$data["\0*\0_parent"]]);
|
||||
$this->filename = $data["\0".self::class."\0filename"];
|
||||
$this->mediaType = $data["\0".self::class."\0mediaType"];
|
||||
|
||||
if ($wakeup) {
|
||||
$this->__wakeup();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
trigger_deprecation('symfony/mime', '7.4', 'Passing extra keys to "%s::__unserialize()" is deprecated, populate properties in "%s::__unserialize()" instead.', self::class, get_debug_type($this));
|
||||
|
||||
\Closure::bind(function ($data) use ($wakeup) {
|
||||
foreach ($data as $key => $value) {
|
||||
$this->{("\0" === $key[0] ?? '') ? substr($key, 1 + strrpos($key, "\0")) : $key} = $value;
|
||||
}
|
||||
|
||||
if ($wakeup) {
|
||||
$this->__wakeup();
|
||||
}
|
||||
}, $this, static::class)($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Symfony 7.4, will be replaced by `__serialize()` in 8.0
|
||||
*/
|
||||
public function __sleep(): array
|
||||
{
|
||||
trigger_deprecation('symfony/mime', '7.4', 'Calling "%s::__sleep()" is deprecated, use "__serialize()" instead.', get_debug_type($this));
|
||||
// converts the body to a string
|
||||
parent::__sleep();
|
||||
|
||||
$this->_parent = [];
|
||||
foreach (['body', 'charset', 'subtype', 'disposition', 'name', 'encoding'] as $name) {
|
||||
$r = new \ReflectionProperty(TextPart::class, $name);
|
||||
$this->_parent[$name] = $r->getValue($this);
|
||||
}
|
||||
$this->_headers = $this->getHeaders();
|
||||
|
||||
return ['_headers', '_parent', 'filename', 'mediaType'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Symfony 7.4, will be replaced by `__unserialize()` in 8.0
|
||||
*/
|
||||
public function __wakeup(): void
|
||||
{
|
||||
$r = new \ReflectionProperty(AbstractPart::class, 'headers');
|
||||
$r->setValue($this, $this->_headers);
|
||||
unset($this->_headers);
|
||||
|
||||
if (!\is_array($this->_parent)) {
|
||||
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
|
||||
}
|
||||
foreach (['body', 'charset', 'subtype', 'disposition', 'name', 'encoding'] as $name) {
|
||||
if (null !== $this->_parent[$name] && !\is_string($this->_parent[$name]) && !$this->_parent[$name] instanceof File) {
|
||||
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
|
||||
}
|
||||
$r = new \ReflectionProperty(TextPart::class, $name);
|
||||
$r->setValue($this, $this->_parent[$name]);
|
||||
}
|
||||
unset($this->_parent);
|
||||
}
|
||||
}
|
||||
51
vendor/symfony/mime/Part/File.php
vendored
Executable file
51
vendor/symfony/mime/Part/File.php
vendored
Executable file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Mime\Part;
|
||||
|
||||
use Symfony\Component\Mime\MimeTypes;
|
||||
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class File
|
||||
{
|
||||
private static MimeTypes $mimeTypes;
|
||||
|
||||
public function __construct(
|
||||
private string $path,
|
||||
private ?string $filename = null,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getPath(): string
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
public function getContentType(): string
|
||||
{
|
||||
$ext = strtolower(pathinfo($this->path, \PATHINFO_EXTENSION));
|
||||
self::$mimeTypes ??= new MimeTypes();
|
||||
|
||||
return self::$mimeTypes->getMimeTypes($ext)[0] ?? 'application/octet-stream';
|
||||
}
|
||||
|
||||
public function getSize(): int
|
||||
{
|
||||
return filesize($this->path);
|
||||
}
|
||||
|
||||
public function getFilename(): string
|
||||
{
|
||||
return $this->filename ??= basename($this->getPath());
|
||||
}
|
||||
}
|
||||
71
vendor/symfony/mime/Part/MessagePart.php
vendored
Executable file
71
vendor/symfony/mime/Part/MessagePart.php
vendored
Executable file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Mime\Part;
|
||||
|
||||
use Symfony\Component\Mime\Message;
|
||||
use Symfony\Component\Mime\RawMessage;
|
||||
|
||||
/**
|
||||
* @final
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class MessagePart extends DataPart
|
||||
{
|
||||
public function __construct(
|
||||
private RawMessage $message,
|
||||
) {
|
||||
if ($message instanceof Message) {
|
||||
$name = $message->getHeaders()->getHeaderBody('Subject').'.eml';
|
||||
} else {
|
||||
$name = 'email.eml';
|
||||
}
|
||||
parent::__construct('', $name);
|
||||
}
|
||||
|
||||
public function getMediaType(): string
|
||||
{
|
||||
return 'message';
|
||||
}
|
||||
|
||||
public function getMediaSubtype(): string
|
||||
{
|
||||
return 'rfc822';
|
||||
}
|
||||
|
||||
public function getBody(): string
|
||||
{
|
||||
return $this->message->toString();
|
||||
}
|
||||
|
||||
public function bodyToString(): string
|
||||
{
|
||||
return $this->getBody();
|
||||
}
|
||||
|
||||
public function bodyToIterable(): iterable
|
||||
{
|
||||
return $this->message->toIterable();
|
||||
}
|
||||
|
||||
public function __serialize(): array
|
||||
{
|
||||
return ['message' => $this->message];
|
||||
}
|
||||
|
||||
public function __unserialize(array $data): void
|
||||
{
|
||||
$this->message = $data['message'] ?? $data["\0".self::class."\0message"];
|
||||
|
||||
$this->__construct($this->message);
|
||||
}
|
||||
}
|
||||
25
vendor/symfony/mime/Part/Multipart/AlternativePart.php
vendored
Executable file
25
vendor/symfony/mime/Part/Multipart/AlternativePart.php
vendored
Executable file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Mime\Part\Multipart;
|
||||
|
||||
use Symfony\Component\Mime\Part\AbstractMultipartPart;
|
||||
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
final class AlternativePart extends AbstractMultipartPart
|
||||
{
|
||||
public function getMediaSubtype(): string
|
||||
{
|
||||
return 'alternative';
|
||||
}
|
||||
}
|
||||
31
vendor/symfony/mime/Part/Multipart/DigestPart.php
vendored
Executable file
31
vendor/symfony/mime/Part/Multipart/DigestPart.php
vendored
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Mime\Part\Multipart;
|
||||
|
||||
use Symfony\Component\Mime\Part\AbstractMultipartPart;
|
||||
use Symfony\Component\Mime\Part\MessagePart;
|
||||
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
final class DigestPart extends AbstractMultipartPart
|
||||
{
|
||||
public function __construct(MessagePart ...$parts)
|
||||
{
|
||||
parent::__construct(...$parts);
|
||||
}
|
||||
|
||||
public function getMediaSubtype(): string
|
||||
{
|
||||
return 'digest';
|
||||
}
|
||||
}
|
||||
104
vendor/symfony/mime/Part/Multipart/FormDataPart.php
vendored
Executable file
104
vendor/symfony/mime/Part/Multipart/FormDataPart.php
vendored
Executable file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Mime\Part\Multipart;
|
||||
|
||||
use Symfony\Component\Mime\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Mime\Part\AbstractMultipartPart;
|
||||
use Symfony\Component\Mime\Part\TextPart;
|
||||
|
||||
/**
|
||||
* Implements RFC 7578.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
final class FormDataPart extends AbstractMultipartPart
|
||||
{
|
||||
/**
|
||||
* @param array<string|array|TextPart> $fields
|
||||
*/
|
||||
public function __construct(
|
||||
private array $fields = [],
|
||||
) {
|
||||
parent::__construct();
|
||||
|
||||
// HTTP does not support \r\n in header values
|
||||
$this->getHeaders()->setMaxLineLength(\PHP_INT_MAX);
|
||||
}
|
||||
|
||||
public function getMediaSubtype(): string
|
||||
{
|
||||
return 'form-data';
|
||||
}
|
||||
|
||||
public function getParts(): array
|
||||
{
|
||||
return $this->prepareFields($this->fields);
|
||||
}
|
||||
|
||||
private function prepareFields(array $fields): array
|
||||
{
|
||||
$values = [];
|
||||
|
||||
$prepare = function ($item, $key, $root = null) use (&$values, &$prepare) {
|
||||
if (null === $root && \is_int($key) && \is_array($item)) {
|
||||
if (1 !== \count($item)) {
|
||||
throw new InvalidArgumentException(\sprintf('Form field values with integer keys can only have one array element, the key being the field name and the value being the field value, %d provided.', \count($item)));
|
||||
}
|
||||
|
||||
$key = key($item);
|
||||
$item = $item[$key];
|
||||
}
|
||||
|
||||
$fieldName = null !== $root ? \sprintf('%s[%s]', $root, $key) : $key;
|
||||
|
||||
if (\is_array($item)) {
|
||||
array_walk($item, $prepare, $fieldName);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!\is_string($item) && !$item instanceof TextPart) {
|
||||
throw new InvalidArgumentException(\sprintf('The value of the form field "%s" can only be a string, an array, or an instance of TextPart, "%s" given.', $fieldName, get_debug_type($item)));
|
||||
}
|
||||
|
||||
$values[] = $this->preparePart($fieldName, $item);
|
||||
};
|
||||
|
||||
array_walk($fields, $prepare);
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
private function preparePart(string $name, string|TextPart $value): TextPart
|
||||
{
|
||||
if (\is_string($value)) {
|
||||
return $this->configurePart($name, new TextPart($value, 'utf-8', 'plain', '8bit'));
|
||||
}
|
||||
|
||||
return $this->configurePart($name, $value);
|
||||
}
|
||||
|
||||
private function configurePart(string $name, TextPart $part): TextPart
|
||||
{
|
||||
static $r;
|
||||
|
||||
$r ??= new \ReflectionProperty(TextPart::class, 'encoding');
|
||||
|
||||
$part->setDisposition('form-data');
|
||||
$part->setName($name);
|
||||
// HTTP does not support \r\n in header values
|
||||
$part->getHeaders()->setMaxLineLength(\PHP_INT_MAX);
|
||||
$r->setValue($part, '8bit');
|
||||
|
||||
return $part;
|
||||
}
|
||||
}
|
||||
25
vendor/symfony/mime/Part/Multipart/MixedPart.php
vendored
Executable file
25
vendor/symfony/mime/Part/Multipart/MixedPart.php
vendored
Executable file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Mime\Part\Multipart;
|
||||
|
||||
use Symfony\Component\Mime\Part\AbstractMultipartPart;
|
||||
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
final class MixedPart extends AbstractMultipartPart
|
||||
{
|
||||
public function getMediaSubtype(): string
|
||||
{
|
||||
return 'mixed';
|
||||
}
|
||||
}
|
||||
55
vendor/symfony/mime/Part/Multipart/RelatedPart.php
vendored
Executable file
55
vendor/symfony/mime/Part/Multipart/RelatedPart.php
vendored
Executable file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Mime\Part\Multipart;
|
||||
|
||||
use Symfony\Component\Mime\Part\AbstractMultipartPart;
|
||||
use Symfony\Component\Mime\Part\AbstractPart;
|
||||
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
final class RelatedPart extends AbstractMultipartPart
|
||||
{
|
||||
public function __construct(
|
||||
private AbstractPart $mainPart,
|
||||
AbstractPart $part,
|
||||
AbstractPart ...$parts,
|
||||
) {
|
||||
$this->prepareParts($part, ...$parts);
|
||||
|
||||
parent::__construct($part, ...$parts);
|
||||
}
|
||||
|
||||
public function getParts(): array
|
||||
{
|
||||
return array_merge([$this->mainPart], parent::getParts());
|
||||
}
|
||||
|
||||
public function getMediaSubtype(): string
|
||||
{
|
||||
return 'related';
|
||||
}
|
||||
|
||||
private function generateContentId(): string
|
||||
{
|
||||
return bin2hex(random_bytes(16)).'@symfony';
|
||||
}
|
||||
|
||||
private function prepareParts(AbstractPart ...$parts): void
|
||||
{
|
||||
foreach ($parts as $part) {
|
||||
if (!$part->getHeaders()->has('Content-ID')) {
|
||||
$part->getHeaders()->setHeaderBody('Id', 'Content-ID', $this->generateContentId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
199
vendor/symfony/mime/Part/SMimePart.php
vendored
Executable file
199
vendor/symfony/mime/Part/SMimePart.php
vendored
Executable file
@@ -0,0 +1,199 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Mime\Part;
|
||||
|
||||
use Symfony\Component\Mime\Header\Headers;
|
||||
|
||||
/**
|
||||
* @author Sebastiaan Stok <s.stok@rollerscapes.net>
|
||||
*/
|
||||
class SMimePart extends AbstractPart
|
||||
{
|
||||
/** @internal, to be removed in 8.0 */
|
||||
protected Headers $_headers;
|
||||
|
||||
public function __construct(
|
||||
private iterable|string $body,
|
||||
private string $type,
|
||||
private string $subtype,
|
||||
private array $parameters,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function getMediaType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function getMediaSubtype(): string
|
||||
{
|
||||
return $this->subtype;
|
||||
}
|
||||
|
||||
public function bodyToString(): string
|
||||
{
|
||||
if (\is_string($this->body)) {
|
||||
return $this->body;
|
||||
}
|
||||
|
||||
$body = '';
|
||||
foreach ($this->body as $chunk) {
|
||||
$body .= $chunk;
|
||||
}
|
||||
$this->body = $body;
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
public function bodyToIterable(): iterable
|
||||
{
|
||||
if (\is_string($this->body)) {
|
||||
yield $this->body;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$body = '';
|
||||
foreach ($this->body as $chunk) {
|
||||
$body .= $chunk;
|
||||
yield $chunk;
|
||||
}
|
||||
$this->body = $body;
|
||||
}
|
||||
|
||||
public function getPreparedHeaders(): Headers
|
||||
{
|
||||
$headers = clone parent::getHeaders();
|
||||
|
||||
$headers->setHeaderBody('Parameterized', 'Content-Type', $this->getMediaType().'/'.$this->getMediaSubtype());
|
||||
|
||||
foreach ($this->parameters as $name => $value) {
|
||||
$headers->setHeaderParameter('Content-Type', $name, $value);
|
||||
}
|
||||
|
||||
return $headers;
|
||||
}
|
||||
|
||||
public function __serialize(): array
|
||||
{
|
||||
if (self::class === (new \ReflectionMethod($this, '__sleep'))->class || self::class !== (new \ReflectionMethod($this, '__serialize'))->class) {
|
||||
// convert iterables to strings for serialization
|
||||
if (is_iterable($this->body)) {
|
||||
$this->body = $this->bodyToString();
|
||||
}
|
||||
|
||||
return [
|
||||
'_headers' => $this->getHeaders(),
|
||||
'body' => $this->body,
|
||||
'type' => $this->type,
|
||||
'subtype' => $this->subtype,
|
||||
'parameters' => $this->parameters,
|
||||
];
|
||||
}
|
||||
|
||||
trigger_deprecation('symfony/mime', '7.4', 'Implementing "%s::__sleep()" is deprecated, use "__serialize()" instead.', get_debug_type($this));
|
||||
|
||||
$data = [];
|
||||
foreach ($this->__sleep() as $key) {
|
||||
try {
|
||||
if (($r = new \ReflectionProperty($this, $key))->isInitialized($this)) {
|
||||
$data[$key] = $r->getValue($this);
|
||||
}
|
||||
} catch (\ReflectionException) {
|
||||
$data[$key] = $this->$key;
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function __unserialize(array $data): void
|
||||
{
|
||||
if ($wakeup = self::class !== (new \ReflectionMethod($this, '__wakeup'))->class && self::class === (new \ReflectionMethod($this, '__unserialize'))->class) {
|
||||
trigger_deprecation('symfony/mime', '7.4', 'Implementing "%s::__wakeup()" is deprecated, use "__unserialize()" instead.', get_debug_type($this));
|
||||
}
|
||||
|
||||
if (['_headers', 'body', 'type', 'subtype', 'parameters'] === array_keys($data)) {
|
||||
parent::__unserialize(['headers' => $data['_headers']]);
|
||||
$this->body = $data['body'];
|
||||
$this->type = $data['type'];
|
||||
$this->subtype = $data['subtype'];
|
||||
$this->parameters = $data['parameters'];
|
||||
|
||||
if ($wakeup) {
|
||||
$this->__wakeup();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$p = "\0".self::class."\0";
|
||||
if (["\0*\0_headers", $p.'body', $p.'type', $p.'subtype', $p.'parameters'] === array_keys($data)) {
|
||||
$r = new \ReflectionProperty(parent::class, 'headers');
|
||||
$r->setValue($this, $data["\0*\0_headers"]);
|
||||
|
||||
$this->body = $data[$p.'body'];
|
||||
$this->type = $data[$p.'type'];
|
||||
$this->subtype = $data[$p.'subtype'];
|
||||
$this->parameters = $data[$p.'parameters'];
|
||||
|
||||
if ($wakeup) {
|
||||
$this->_headers = $data["\0*\0_headers"];
|
||||
$this->__wakeup();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
trigger_deprecation('symfony/mime', '7.4', 'Passing extra keys to "%s::__unserialize()" is deprecated, populate properties in "%s::__unserialize()" instead.', self::class, get_debug_type($this));
|
||||
|
||||
\Closure::bind(function ($data) use ($wakeup) {
|
||||
foreach ($data as $key => $value) {
|
||||
$this->{("\0" === $key[0] ?? '') ? substr($key, 1 + strrpos($key, "\0")) : $key} = $value;
|
||||
}
|
||||
|
||||
if ($wakeup) {
|
||||
$this->__wakeup();
|
||||
}
|
||||
}, $this, static::class)($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Symfony 7.4, will be replaced by `__serialize()` in 8.0
|
||||
*/
|
||||
public function __sleep(): array
|
||||
{
|
||||
trigger_deprecation('symfony/mime', '7.4', 'Calling "%s::__sleep()" is deprecated, use "__serialize()" instead.', get_debug_type($this));
|
||||
|
||||
// convert iterables to strings for serialization
|
||||
if (is_iterable($this->body)) {
|
||||
$this->body = $this->bodyToString();
|
||||
}
|
||||
|
||||
$this->_headers = $this->getHeaders();
|
||||
|
||||
return ['_headers', 'body', 'type', 'subtype', 'parameters'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Symfony 7.4, will be replaced by `__unserialize()` in 8.0
|
||||
*/
|
||||
public function __wakeup(): void
|
||||
{
|
||||
trigger_deprecation('symfony/mime', '7.4', 'Calling "%s::__wakeup()" is deprecated, use "__unserialize()" instead.', get_debug_type($this));
|
||||
|
||||
$r = new \ReflectionProperty(AbstractPart::class, 'headers');
|
||||
$r->setValue($this, $this->_headers);
|
||||
unset($this->_headers);
|
||||
}
|
||||
}
|
||||
366
vendor/symfony/mime/Part/TextPart.php
vendored
Executable file
366
vendor/symfony/mime/Part/TextPart.php
vendored
Executable file
@@ -0,0 +1,366 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Mime\Part;
|
||||
|
||||
use Symfony\Component\Mime\Encoder\Base64ContentEncoder;
|
||||
use Symfony\Component\Mime\Encoder\ContentEncoderInterface;
|
||||
use Symfony\Component\Mime\Encoder\EightBitContentEncoder;
|
||||
use Symfony\Component\Mime\Encoder\QpContentEncoder;
|
||||
use Symfony\Component\Mime\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Mime\Header\Headers;
|
||||
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class TextPart extends AbstractPart
|
||||
{
|
||||
private const DEFAULT_ENCODERS = ['quoted-printable', 'base64', '8bit'];
|
||||
|
||||
/** @internal, to be removed in 8.0 */
|
||||
protected Headers $_headers;
|
||||
|
||||
private static array $encoders = [];
|
||||
|
||||
/** @var resource|string|File */
|
||||
private $body;
|
||||
private ?string $charset;
|
||||
private string $subtype;
|
||||
private ?string $disposition = null;
|
||||
private ?string $name = null;
|
||||
private string $encoding;
|
||||
private ?bool $seekable = null;
|
||||
|
||||
/**
|
||||
* @param resource|string|File $body Use a File instance to defer loading the file until rendering
|
||||
*/
|
||||
public function __construct($body, ?string $charset = 'utf-8', string $subtype = 'plain', ?string $encoding = null)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
if (!\is_string($body) && !\is_resource($body) && !$body instanceof File) {
|
||||
throw new \TypeError(\sprintf('The body of "%s" must be a string, a resource, or an instance of "%s" (got "%s").', self::class, File::class, get_debug_type($body)));
|
||||
}
|
||||
|
||||
if ($body instanceof File) {
|
||||
$path = $body->getPath();
|
||||
if ((is_file($path) && !is_readable($path)) || is_dir($path)) {
|
||||
throw new InvalidArgumentException(\sprintf('Path "%s" is not readable.', $path));
|
||||
}
|
||||
}
|
||||
|
||||
$this->body = $body;
|
||||
$this->charset = $charset;
|
||||
$this->subtype = $subtype;
|
||||
$this->seekable = \is_resource($body) ? stream_get_meta_data($body)['seekable'] && 0 === fseek($body, 0, \SEEK_CUR) : null;
|
||||
|
||||
if (null === $encoding) {
|
||||
$this->encoding = $this->chooseEncoding();
|
||||
} else {
|
||||
if (!\in_array($encoding, self::DEFAULT_ENCODERS, true) && !\array_key_exists($encoding, self::$encoders)) {
|
||||
throw new InvalidArgumentException(\sprintf('The encoding must be one of "%s" ("%s" given).', implode('", "', array_unique(array_merge(self::DEFAULT_ENCODERS, array_keys(self::$encoders)))), $encoding));
|
||||
}
|
||||
$this->encoding = $encoding;
|
||||
}
|
||||
}
|
||||
|
||||
public function getMediaType(): string
|
||||
{
|
||||
return 'text';
|
||||
}
|
||||
|
||||
public function getMediaSubtype(): string
|
||||
{
|
||||
return $this->subtype;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $disposition one of attachment, inline, or form-data
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDisposition(string $disposition): static
|
||||
{
|
||||
$this->disposition = $disposition;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ?string null or one of attachment, inline, or form-data
|
||||
*/
|
||||
public function getDisposition(): ?string
|
||||
{
|
||||
return $this->disposition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name of the file (used by FormDataPart).
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setName(string $name): static
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of the file.
|
||||
*/
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getBody(): string
|
||||
{
|
||||
if ($this->body instanceof File) {
|
||||
if (false === $ret = @file_get_contents($this->body->getPath())) {
|
||||
throw new InvalidArgumentException(error_get_last()['message']);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
if (null === $this->seekable) {
|
||||
return $this->body;
|
||||
}
|
||||
|
||||
if ($this->seekable) {
|
||||
rewind($this->body);
|
||||
}
|
||||
|
||||
return stream_get_contents($this->body) ?: '';
|
||||
}
|
||||
|
||||
public function bodyToString(): string
|
||||
{
|
||||
return $this->getEncoder()->encodeString($this->getBody(), $this->charset);
|
||||
}
|
||||
|
||||
public function bodyToIterable(): iterable
|
||||
{
|
||||
if ($this->body instanceof File) {
|
||||
$path = $this->body->getPath();
|
||||
if (false === $handle = @fopen($path, 'r', false)) {
|
||||
throw new InvalidArgumentException(\sprintf('Unable to open path "%s".', $path));
|
||||
}
|
||||
|
||||
yield from $this->getEncoder()->encodeByteStream($handle);
|
||||
} elseif (null !== $this->seekable) {
|
||||
if ($this->seekable) {
|
||||
rewind($this->body);
|
||||
}
|
||||
yield from $this->getEncoder()->encodeByteStream($this->body);
|
||||
} else {
|
||||
yield $this->getEncoder()->encodeString($this->body);
|
||||
}
|
||||
}
|
||||
|
||||
public function getPreparedHeaders(): Headers
|
||||
{
|
||||
$headers = parent::getPreparedHeaders();
|
||||
|
||||
$headers->setHeaderBody('Parameterized', 'Content-Type', $this->getMediaType().'/'.$this->getMediaSubtype());
|
||||
if ($this->charset) {
|
||||
$headers->setHeaderParameter('Content-Type', 'charset', $this->charset);
|
||||
}
|
||||
if ($this->name && 'form-data' !== $this->disposition) {
|
||||
$headers->setHeaderParameter('Content-Type', 'name', $this->name);
|
||||
}
|
||||
$headers->setHeaderBody('Text', 'Content-Transfer-Encoding', $this->encoding);
|
||||
|
||||
if (!$headers->has('Content-Disposition') && null !== $this->disposition) {
|
||||
$headers->setHeaderBody('Parameterized', 'Content-Disposition', $this->disposition);
|
||||
if ($this->name) {
|
||||
$headers->setHeaderParameter('Content-Disposition', 'name', $this->name);
|
||||
}
|
||||
}
|
||||
|
||||
return $headers;
|
||||
}
|
||||
|
||||
public function asDebugString(): string
|
||||
{
|
||||
$str = parent::asDebugString();
|
||||
if (null !== $this->charset) {
|
||||
$str .= ' charset: '.$this->charset;
|
||||
}
|
||||
if (null !== $this->disposition) {
|
||||
$str .= ' disposition: '.$this->disposition;
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
private function getEncoder(): ContentEncoderInterface
|
||||
{
|
||||
if ('8bit' === $this->encoding) {
|
||||
return self::$encoders[$this->encoding] ??= new EightBitContentEncoder();
|
||||
}
|
||||
|
||||
if ('quoted-printable' === $this->encoding) {
|
||||
return self::$encoders[$this->encoding] ??= new QpContentEncoder();
|
||||
}
|
||||
|
||||
if ('base64' === $this->encoding) {
|
||||
return self::$encoders[$this->encoding] ??= new Base64ContentEncoder();
|
||||
}
|
||||
|
||||
return self::$encoders[$this->encoding];
|
||||
}
|
||||
|
||||
public static function addEncoder(ContentEncoderInterface $encoder): void
|
||||
{
|
||||
if (\in_array($encoder->getName(), self::DEFAULT_ENCODERS, true)) {
|
||||
throw new InvalidArgumentException('You are not allowed to change the default encoders ("quoted-printable", "base64", and "8bit").');
|
||||
}
|
||||
|
||||
self::$encoders[$encoder->getName()] = $encoder;
|
||||
}
|
||||
|
||||
private function chooseEncoding(): string
|
||||
{
|
||||
if (null === $this->charset) {
|
||||
return 'base64';
|
||||
}
|
||||
|
||||
return 'quoted-printable';
|
||||
}
|
||||
|
||||
public function __serialize(): array
|
||||
{
|
||||
if (self::class === (new \ReflectionMethod($this, '__sleep'))->class || self::class !== (new \ReflectionMethod($this, '__serialize'))->class) {
|
||||
// convert resources to strings for serialization
|
||||
if (null !== $this->seekable) {
|
||||
$this->body = $this->getBody();
|
||||
$this->seekable = null;
|
||||
}
|
||||
|
||||
return [
|
||||
'_headers' => $this->getHeaders(),
|
||||
'body' => $this->body,
|
||||
'charset' => $this->charset,
|
||||
'subtype' => $this->subtype,
|
||||
'disposition' => $this->disposition,
|
||||
'name' => $this->name,
|
||||
'encoding' => $this->encoding,
|
||||
];
|
||||
}
|
||||
|
||||
trigger_deprecation('symfony/mime', '7.4', 'Implementing "%s::__sleep()" is deprecated, use "__serialize()" instead.', get_debug_type($this));
|
||||
|
||||
$data = [];
|
||||
foreach ($this->__sleep() as $key) {
|
||||
try {
|
||||
if (($r = new \ReflectionProperty($this, $key))->isInitialized($this)) {
|
||||
$data[$key] = $r->getValue($this);
|
||||
}
|
||||
} catch (\ReflectionException) {
|
||||
$data[$key] = $this->$key;
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function __unserialize(array $data): void
|
||||
{
|
||||
if ($wakeup = self::class !== (new \ReflectionMethod($this, '__wakeup'))->class && self::class === (new \ReflectionMethod($this, '__unserialize'))->class) {
|
||||
trigger_deprecation('symfony/mime', '7.4', 'Implementing "%s::__wakeup()" is deprecated, use "__unserialize()" instead.', get_debug_type($this));
|
||||
}
|
||||
|
||||
if ($headers = $data['_headers'] ?? $data["\0*\0_headers"] ?? null) {
|
||||
unset($data['_headers'], $data["\0*\0_headers"]);
|
||||
parent::__unserialize(['headers' => $headers]);
|
||||
}
|
||||
|
||||
if (['body', 'charset', 'subtype', 'disposition', 'name', 'encoding'] === array_keys($data)) {
|
||||
parent::__unserialize(['headers' => $headers]);
|
||||
$this->body = $data['body'];
|
||||
$this->charset = $data['charset'];
|
||||
$this->subtype = $data['subtype'];
|
||||
$this->disposition = $data['disposition'];
|
||||
$this->name = $data['name'];
|
||||
$this->encoding = $data['encoding'];
|
||||
|
||||
if ($wakeup) {
|
||||
$this->__wakeup();
|
||||
} elseif (!\is_string($this->body) && !$this->body instanceof File) {
|
||||
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (["\0".self::class."\0body", "\0".self::class."\0charset", "\0".self::class."\0subtype", "\0".self::class."\0disposition", "\0".self::class."\0name", "\0".self::class."\0encoding"] === array_keys($data)) {
|
||||
$this->body = $data["\0".self::class."\0body"];
|
||||
$this->charset = $data["\0".self::class."\0charset"];
|
||||
$this->subtype = $data["\0".self::class."\0subtype"];
|
||||
$this->disposition = $data["\0".self::class."\0disposition"];
|
||||
$this->name = $data["\0".self::class."\0name"];
|
||||
$this->encoding = $data["\0".self::class."\0encoding"];
|
||||
|
||||
if ($wakeup) {
|
||||
$this->_headers = $headers;
|
||||
$this->__wakeup();
|
||||
} elseif (!\is_string($this->body) && !$this->body instanceof File) {
|
||||
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
trigger_deprecation('symfony/mime', '7.4', 'Passing extra keys to "%s::__unserialize()" is deprecated, populate properties in "%s::__unserialize()" instead.', self::class, get_debug_type($this));
|
||||
|
||||
\Closure::bind(function ($data) use ($wakeup) {
|
||||
foreach ($data as $key => $value) {
|
||||
$this->{("\0" === $key[0] ?? '') ? substr($key, 1 + strrpos($key, "\0")) : $key} = $value;
|
||||
}
|
||||
|
||||
if ($wakeup) {
|
||||
$this->__wakeup();
|
||||
}
|
||||
}, $this, static::class)($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Symfony 7.4, will be replaced by `__serialize()` in 8.0
|
||||
*/
|
||||
public function __sleep(): array
|
||||
{
|
||||
trigger_deprecation('symfony/mime', '7.4', 'Calling "%s::__sleep()" is deprecated, use "__serialize()" instead.', get_debug_type($this));
|
||||
|
||||
// convert resources to strings for serialization
|
||||
if (null !== $this->seekable) {
|
||||
$this->body = $this->getBody();
|
||||
$this->seekable = null;
|
||||
}
|
||||
|
||||
$this->_headers = $this->getHeaders();
|
||||
|
||||
return ['_headers', 'body', 'charset', 'subtype', 'disposition', 'name', 'encoding'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Symfony 7.4, will be replaced by `__unserialize()` in 8.0
|
||||
*/
|
||||
public function __wakeup(): void
|
||||
{
|
||||
trigger_deprecation('symfony/mime', '7.4', 'Calling "%s::__wakeup()" is deprecated, use "__unserialize()" instead.', get_debug_type($this));
|
||||
|
||||
$r = new \ReflectionProperty(AbstractPart::class, 'headers');
|
||||
$r->setValue($this, $this->_headers);
|
||||
unset($this->_headers);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user