Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DataPart.php

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\Part

Code

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');
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal