feature #32917 [Mime] Add AbstractPart::asDebugString() (fabpot)
This PR was merged into the 4.4 branch.
Discussion
----------
[Mime] Add AbstractPart::asDebugString()
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | no
| New feature? | yes
| BC breaks? | no <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass? | yes <!-- please add some, will be required by reviewers -->
| Fixed tickets | n/a
| License | MIT
| Doc PR | n/a
That helps debugging issues and will be displayed in the web profiler Mailer panel.
Commits
-------
f36c8c9881
[Mime] added AbstractPart::asDebugString()
This commit is contained in:
commit
1ce83dab34
@ -1,6 +1,11 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
4.4.0
|
||||
-----
|
||||
|
||||
* Added `AbstractPart::asDebugString()`
|
||||
|
||||
4.3.3
|
||||
-----
|
||||
|
||||
|
@ -74,6 +74,20 @@ abstract class AbstractMultipartPart extends AbstractPart
|
||||
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
|
||||
{
|
||||
if (null === $this->boundary) {
|
||||
|
@ -50,6 +50,11 @@ abstract class AbstractPart
|
||||
yield from $this->bodyToIterable();
|
||||
}
|
||||
|
||||
public function asDebugString(): string
|
||||
{
|
||||
return $this->getMediaType().'/'.$this->getMediaSubtype();
|
||||
}
|
||||
|
||||
abstract public function bodyToString(): string;
|
||||
|
||||
abstract public function bodyToIterable(): iterable;
|
||||
|
@ -103,6 +103,16 @@ class DataPart extends TextPart
|
||||
return $headers;
|
||||
}
|
||||
|
||||
public function asDebugString(): string
|
||||
{
|
||||
$str = parent::asDebugString();
|
||||
if (null !== $this->filename) {
|
||||
$str .= ' filename: '.$this->filename;
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
private function generateContentId(): string
|
||||
{
|
||||
return bin2hex(random_bytes(16)).'@symfony';
|
||||
|
@ -144,6 +144,19 @@ class TextPart extends AbstractPart
|
||||
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) {
|
||||
|
Reference in New Issue
Block a user