final class FrontMatter (View source)

internal  This front matter extractor only supports help topic discovery and is not part of the public API.
 

Extracts Front Matter from the beginning of a source.

Constants

FRONT_MATTER_SEPARATOR

The separator used to indicate front matter data.

FRONT_MATTER_REGEXP

The regular expression used to extract the YAML front matter content.

Properties

protected array $parsed

The parsed source.

protected string $serializer

A serializer class.

protected string $source

The source.

Methods

__construct(string $source, string $serializer = '\\Drupal\\Component\\Serialization\\Yaml')

FrontMatter constructor.

static FrontMatter
load(string $source, string $serializer = '\\Drupal\\Component\\Serialization\\Yaml')

Creates a new FrontMatter instance.

string
getCode()

Retrieves the extracted source code.

array
getData()

Retrieves the extracted front matter data.

int
getLine()

Retrieves the line where the source code starts, after any data.

Details

__construct(string $source, string $serializer = '\\Drupal\\Component\\Serialization\\Yaml')

FrontMatter constructor.

Parameters

string $source

A string source.

string $serializer

A class that implements \Drupal\Component\Serialization\SerializationInterface.

static FrontMatter load(string $source, string $serializer = '\\Drupal\\Component\\Serialization\\Yaml')

Creates a new FrontMatter instance.

Parameters

string $source

A string source.

string $serializer

A class that implements \Drupal\Component\Serialization\SerializationInterface.

Return Value

FrontMatter

string getCode()

Retrieves the extracted source code.

Return Value

string

The extracted source code.

Exceptions

InvalidDataTypeException

array getData()

Retrieves the extracted front matter data.

Return Value

array

The extracted front matter data.

Exceptions

InvalidDataTypeException

int getLine()

Retrieves the line where the source code starts, after any data.

Return Value

int

The source code line.

Exceptions

InvalidDataTypeException