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

Breadcrumb

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

function RawMessage::toIterable

1 method overrides RawMessage::toIterable()
Message::toIterable in vendor/symfony/mime/Message.php

File

vendor/symfony/mime/RawMessage.php, line 56

Class

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

Namespace

Symfony\Component\Mime

Code

public function toIterable() : iterable {
    if ($this->isGeneratorClosed ?? false) {
        throw new LogicException('Unable to send the email as its generator is already closed.');
    }
    if (\is_string($this->message)) {
        (yield $this->message);
        return;
    }
    if (\is_resource($this->message)) {
        rewind($this->message);
        while ($line = fgets($this->message)) {
            (yield $line);
        }
        return;
    }
    if ($this->message instanceof \Generator) {
        $message = fopen('php://temp', 'w+');
        foreach ($this->message as $chunk) {
            fwrite($message, $chunk);
            (yield $chunk);
        }
        $this->isGeneratorClosed = !$this->message
            ->valid();
        $this->message = $message;
        return;
    }
    foreach ($this->message as $chunk) {
        (yield $chunk);
    }
}
RSS feed
Powered by Drupal