function FrontMatter::__construct

Same name in other branches
  1. 8.9.x core/modules/help_topics/src/FrontMatter.php \Drupal\help_topics\FrontMatter::__construct()
  2. 10 core/lib/Drupal/Component/FrontMatter/FrontMatter.php \Drupal\Component\FrontMatter\FrontMatter::__construct()
  3. 11.x core/lib/Drupal/Component/FrontMatter/FrontMatter.php \Drupal\Component\FrontMatter\FrontMatter::__construct()

FrontMatter constructor.

Parameters

string $source: A string source.

string $serializer: The name of a class that implements \Drupal\Component\Serialization\SerializationInterface.

File

core/lib/Drupal/Component/FrontMatter/FrontMatter.php, line 89

Class

FrontMatter
Component for parsing front matter from a source.

Namespace

Drupal\Component\FrontMatter

Code

public function __construct(string $source, string $serializer = '\\Drupal\\Component\\Serialization\\Yaml') {
    assert(is_subclass_of($serializer, SerializationInterface::class), sprintf('The $serializer parameter must reference a class that implements %s.', SerializationInterface::class));
    $this->serializer = $serializer;
    $this->source = $source;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.