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

Breadcrumb

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

class IdentificationHeader

An ID MIME Header for something like Message-ID or Content-ID (one or more addresses).

@author Chris Corbyn

Hierarchy

  • class \Symfony\Component\Mime\Header\AbstractHeader implements \Symfony\Component\Mime\Header\HeaderInterface
    • class \Symfony\Component\Mime\Header\IdentificationHeader extends \Symfony\Component\Mime\Header\AbstractHeader

Expanded class hierarchy of IdentificationHeader

File

vendor/symfony/mime/Header/IdentificationHeader.php, line 22

Namespace

Symfony\Component\Mime\Header
View source
final class IdentificationHeader extends AbstractHeader {
    private array $ids = [];
    private array $idsAsAddresses = [];
    public function __construct(string $name, string|array $ids) {
        parent::__construct($name);
        $this->setId($ids);
    }
    
    /**
     * @param string|string[] $body a string ID or an array of IDs
     *
     * @throws RfcComplianceException
     */
    public function setBody(mixed $body) : void {
        $this->setId($body);
    }
    public function getBody() : array {
        return $this->getIds();
    }
    
    /**
     * Set the ID used in the value of this header.
     *
     * @param string|string[] $id
     *
     * @throws RfcComplianceException
     */
    public function setId(string|array $id) : void {
        $this->setIds(\is_array($id) ? $id : [
            $id,
        ]);
    }
    
    /**
     * Get the ID used in the value of this Header.
     *
     * If multiple IDs are set only the first is returned.
     */
    public function getId() : ?string {
        return $this->ids[0] ?? null;
    }
    
    /**
     * Set a collection of IDs to use in the value of this Header.
     *
     * @param string[] $ids
     *
     * @throws RfcComplianceException
     */
    public function setIds(array $ids) : void {
        $this->ids = [];
        $this->idsAsAddresses = [];
        foreach ($ids as $id) {
            $this->idsAsAddresses[] = new Address($id);
            $this->ids[] = $id;
        }
    }
    
    /**
     * Get the list of IDs used in this Header.
     *
     * @return string[]
     */
    public function getIds() : array {
        return $this->ids;
    }
    public function getBodyAsString() : string {
        $addrs = [];
        foreach ($this->idsAsAddresses as $address) {
            $addrs[] = '<' . $address->toString() . '>';
        }
        return implode(' ', $addrs);
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
AbstractHeader::$charset private property
AbstractHeader::$encoder private static property 1
AbstractHeader::$lang private property
AbstractHeader::$lineLength private property
AbstractHeader::$name private property
AbstractHeader::createPhrase protected function Produces a compliant, formatted RFC 2822 &#039;phrase&#039; based on the string given.
AbstractHeader::encodeWords protected function Encode needed word tokens within a string of input.
AbstractHeader::generateTokenLines protected function Generates tokens from the given string which include CRLF as individual tokens.
AbstractHeader::getCharset public function Overrides HeaderInterface::getCharset
AbstractHeader::getEncodableWordTokens protected function Splits a string into tokens in blocks of words which can be encoded quickly.
AbstractHeader::getLanguage public function Overrides HeaderInterface::getLanguage
AbstractHeader::getMaxLineLength public function Overrides HeaderInterface::getMaxLineLength
AbstractHeader::getName public function Overrides HeaderInterface::getName
AbstractHeader::getTokenAsEncodedWord protected function Get a token as an encoded word for safe insertion into headers.
AbstractHeader::PHRASE_PATTERN public constant
AbstractHeader::setCharset public function Overrides HeaderInterface::setCharset
AbstractHeader::setLanguage public function Set the language used in this Header. Overrides HeaderInterface::setLanguage
AbstractHeader::setMaxLineLength public function Overrides HeaderInterface::setMaxLineLength
AbstractHeader::tokenNeedsEncoding protected function 2
AbstractHeader::tokensToString private function Takes an array of tokens which appear in the header and turns them into
an RFC 2822 compliant string, adding FWSP where needed.
AbstractHeader::toString public function Gets this Header rendered as a compliant string. Overrides HeaderInterface::toString
AbstractHeader::toTokens protected function Generate a list of all tokens in the final header. 1
IdentificationHeader::$ids private property
IdentificationHeader::$idsAsAddresses private property
IdentificationHeader::getBody public function Gets the body. Overrides HeaderInterface::getBody
IdentificationHeader::getBodyAsString public function Gets the header&#039;s body, prepared for folding into a final header value. Overrides HeaderInterface::getBodyAsString
IdentificationHeader::getId public function Get the ID used in the value of this Header.
IdentificationHeader::getIds public function Get the list of IDs used in this Header.
IdentificationHeader::setBody public function Overrides HeaderInterface::setBody
IdentificationHeader::setId public function Set the ID used in the value of this header.
IdentificationHeader::setIds public function Set a collection of IDs to use in the value of this Header.
IdentificationHeader::__construct public function Overrides AbstractHeader::__construct

API Navigation

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