Skip to content

Commit 1ce83da

Browse files
committed
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 ------- f36c8c9 [Mime] added AbstractPart::asDebugString()
2 parents 158fe2a + f36c8c9 commit 1ce83da

File tree

5 files changed

+47
-0
lines changed

5 files changed

+47
-0
lines changed

src/Symfony/Component/Mime/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
4.4.0
5+
-----
6+
7+
* Added `AbstractPart::asDebugString()`
8+
49
4.3.3
510
-----
611

src/Symfony/Component/Mime/Part/AbstractMultipartPart.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,20 @@ public function bodyToIterable(): iterable
7474
yield '--'.$this->getBoundary()."--\r\n";
7575
}
7676

77+
public function asDebugString(): string
78+
{
79+
$str = parent::asDebugString();
80+
foreach ($this->getParts() as $part) {
81+
$lines = explode("\n", $part->asDebugString());
82+
$str .= "\n".array_shift($lines);
83+
foreach ($lines as $line) {
84+
$str .= "\n |".$line;
85+
}
86+
}
87+
88+
return $str;
89+
}
90+
7791
private function getBoundary(): string
7892
{
7993
if (null === $this->boundary) {

src/Symfony/Component/Mime/Part/AbstractPart.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ public function toIterable(): iterable
5050
yield from $this->bodyToIterable();
5151
}
5252

53+
public function asDebugString(): string
54+
{
55+
return $this->getMediaType().'/'.$this->getMediaSubtype();
56+
}
57+
5358
abstract public function bodyToString(): string;
5459

5560
abstract public function bodyToIterable(): iterable;

src/Symfony/Component/Mime/Part/DataPart.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,16 @@ public function getPreparedHeaders(): Headers
103103
return $headers;
104104
}
105105

106+
public function asDebugString(): string
107+
{
108+
$str = parent::asDebugString();
109+
if (null !== $this->filename) {
110+
$str .= ' filename: '.$this->filename;
111+
}
112+
113+
return $str;
114+
}
115+
106116
private function generateContentId(): string
107117
{
108118
return bin2hex(random_bytes(16)).'@symfony';

src/Symfony/Component/Mime/Part/TextPart.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,19 @@ public function getPreparedHeaders(): Headers
144144
return $headers;
145145
}
146146

147+
public function asDebugString(): string
148+
{
149+
$str = parent::asDebugString();
150+
if (null !== $this->charset) {
151+
$str .= ' charset: '.$this->charset;
152+
}
153+
if (null !== $this->disposition) {
154+
$str .= ' disposition: '.$this->disposition;
155+
}
156+
157+
return $str;
158+
}
159+
147160
private function getEncoder(): ContentEncoderInterface
148161
{
149162
if ('8bit' === $this->encoding) {

0 commit comments

Comments
 (0)