class TwigTransTokenParser extends AbstractTokenParser (View source)

A class that defines the Twig 'trans' token parser for Drupal.

The token parser converts a token stream created from template source code into an Abstract Syntax Tree (AST). The AST will later be compiled into PHP code usable for runtime execution of the template.

Methods

parse(Token $token)

{@inheritdoc}

decideForFork($token)

Detect a 'plural' switch or the end of a 'trans' tag.

decideForEnd($token)

Detect the end of a 'trans' tag.

getTag()

{@inheritdoc}

checkTransString(Node $body, int $lineno)

Ensure that any nodes that are parsed are only of allowed types.

Details

parse(Token $token)

{@inheritdoc}

Parameters

Token $token

decideForFork($token)

Detect a 'plural' switch or the end of a 'trans' tag.

Parameters

$token

decideForEnd($token)

Detect the end of a 'trans' tag.

Parameters

$token

getTag()

{@inheritdoc}

protected checkTransString(Node $body, int $lineno)

Ensure that any nodes that are parsed are only of allowed types.

Parameters

Node $body

The expression to check.

int $lineno

The source line.

Exceptions

SyntaxError