You are here

public function Translation::__construct in Service Container 7.2

Same name and namespace in other branches
  1. 7 lib/Drupal/Core/Annotation/Translation.php \Drupal\Core\Annotation\Translation::__construct()

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";

File

lib/Drupal/Core/Annotation/Translation.php, line 80
Contains \Drupal\Core\Annotation\Translation.

Class

Translation
Defines a translatable annotation object.

Namespace

Drupal\Core\Annotation

Code

public function __construct(array $values) {
  $string = $values['value'];
  $arguments = isset($values['arguments']) ? $values['arguments'] : array();
  $options = array();
  if (!empty($values['context'])) {
    $options = array(
      'context' => $values['context'],
    );
  }
  $this->translation = new TranslationWrapper($string, $arguments, $options);
}