You are here

public function FrontMatter::__construct in Drupal 8

FrontMatter constructor.

Parameters

string $source: A string source.

string $serializer: A class that implements \Drupal\Component\Serialization\SerializationInterface.

File

core/modules/help_topics/src/FrontMatter.php, line 58

Class

FrontMatter
Extracts Front Matter from the beginning of a source.

Namespace

Drupal\help_topics

Code

public function __construct($source, $serializer = '\\Drupal\\Component\\Serialization\\Yaml') {
  assert(is_string($source), '$source must be a string');
  assert(is_string($serializer), '$serializer must be a string');
  if (!is_subclass_of($serializer, '\\Drupal\\Component\\Serialization\\SerializationInterface')) {
    throw new \InvalidArgumentException('The $serializer parameter must reference a class that implements \\Drupal\\Component\\Serialization\\SerializationInterface.');
  }
  $this->serializer = $serializer;
  $this->source = $source;
}