Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Mime] Simplify code #47034

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions src/Symfony/Component/Mime/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -501,16 +501,11 @@ private function prepareParts(): ?array
$names = array_filter(array_unique($names));
}

// usage of reflection is a temporary workaround for missing getters that will be added in 6.2
$dispositionRef = new \ReflectionProperty(TextPart::class, 'disposition');
$dispositionRef->setAccessible(true);
$nameRef = new \ReflectionProperty(TextPart::class, 'name');
$nameRef->setAccessible(true);
$attachmentParts = $inlineParts = [];
foreach ($this->attachments as $attachment) {
$part = $this->createDataPart($attachment);
if (isset($attachment['part'])) {
$attachment['name'] = $nameRef->getValue($part);
$attachment['name'] = $part->getName();
}

foreach ($names as $name) {
Expand All @@ -527,7 +522,7 @@ private function prepareParts(): ?array
break;
}

if ('inline' === $dispositionRef->getValue($part)) {
if ('inline' === $part->getDisposition()) {
$inlineParts[$attachment['name']] = $part;
} else {
$attachmentParts[] = $part;
Expand Down
7 changes: 6 additions & 1 deletion src/Symfony/Component/Mime/Part/TextPart.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ public function setDisposition(string $disposition): static
return $this;
}

public function getDisposition(): ?string
{
return $this->disposition;
}

/**
* Sets the name of the file (used by FormDataPart).
*
Expand All @@ -102,7 +107,7 @@ public function setName(string $name): static
}

/**
* Gets the name of the file (used by FormDataPart).
* Gets the name of the file.
*/
public function getName(): ?string
{
Expand Down