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

Breadcrumb

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

function TextPart::bodyToIterable

Overrides AbstractPart::bodyToIterable

1 method overrides TextPart::bodyToIterable()
MessagePart::bodyToIterable in vendor/symfony/mime/Part/MessagePart.php

File

vendor/symfony/mime/Part/TextPart.php, line 151

Class

TextPart
@author Fabien Potencier <fabien@symfony.com>

Namespace

Symfony\Component\Mime\Part

Code

public function bodyToIterable() : iterable {
    if ($this->body instanceof File) {
        $path = $this->body
            ->getPath();
        if (false === ($handle = @fopen($path, 'r', false))) {
            throw new InvalidArgumentException(\sprintf('Unable to open path "%s".', $path));
        }
        yield from $this->getEncoder()
            ->encodeByteStream($handle);
    }
    elseif (null !== $this->seekable) {
        if ($this->seekable) {
            rewind($this->body);
        }
        yield from $this->getEncoder()
            ->encodeByteStream($this->body);
    }
    else {
        (yield $this->getEncoder()
            ->encodeString($this->body));
    }
}

API Navigation

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