class Translation extends AnnotationBase (View source)

Defines a translatable annotation object.

Some metadata within an annotation needs to be translatable. This class supports that need by allowing both the translatable string and, if specified, a context for that string. The string (with optional context) is passed into t().

Properties

string $id

The annotated class ID.

from  AnnotationBase
protected string $class

The class used for this annotated class.

from  AnnotationBase
protected string $provider

The provider of the annotated class.

from  AnnotationBase
protected TranslatableMarkup $translation

The string translation object.

Methods

string
getProvider()

Gets the name of the provider of the annotated class.

setProvider(string $provider)

Sets the name of the provider of the annotated class.

string
getId()

Gets the unique ID for this annotated class.

string
getClass()

Gets the class of the annotated class.

setClass(string $class)

Sets the class of the annotated class.

__construct(array $values)

Constructs a new class instance.

get()

Gets the value of an annotation.

Details

string getProvider()

Gets the name of the provider of the annotated class.

Return Value

string

setProvider(string $provider)

Sets the name of the provider of the annotated class.

Parameters

string $provider

The provider of the annotated class.

string getId()

Gets the unique ID for this annotated class.

Return Value

string

string getClass()

Gets the class of the annotated class.

Return Value

string

setClass(string $class)

Sets the class of the annotated class.

Parameters

string $class

The class of the annotated class.

__construct(array $values)

Constructs a new class instance.

Parses values passed into this class through the t() function in Drupal and handles an optional context for the string.

Parameters

array $values

Possible array keys:

  • value (required): the string that is to be translated.
  • arguments (optional): an array with placeholder replacements, keyed by placeholder.
  • context (optional): a string that describes the context of "value";

get()

Gets the value of an annotation.