function DataPart::__construct
Parameters
resource|string|File $body Use a File instance to defer loading the file until rendering:
Overrides TextPart::__construct
2 calls to DataPart::__construct()
- MessagePart::__construct in vendor/
symfony/ mime/ Part/ MessagePart.php - MessagePart::__construct in vendor/
symfony/ mime/ Part/ MessagePart.php
1 method overrides DataPart::__construct()
- MessagePart::__construct in vendor/
symfony/ mime/ Part/ MessagePart.php
File
-
vendor/
symfony/ mime/ Part/ DataPart.php, line 32
Class
- DataPart
- @author Fabien Potencier <fabien@symfony.com>
Namespace
Symfony\Component\Mime\PartCode
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');
}