Elgg  Version 2.3
ArrayMessageBundle.php
Go to the documentation of this file.
1 <?php
2 namespace Elgg\I18n;
3 
16 final class ArrayMessageBundle implements MessageBundle {
17 
19  private $messages;
20 
26  public function __construct(array $messages) {
27  $this->messages = $messages;
28  }
29 
31  public function get($key, Locale $locale) {
32  assert(is_string($key), '$key must be a string');
33 
34  if (!isset($this->messages["$locale"]) || !is_array($this->messages["$locale"])) {
35  return null;
36  }
37 
38  $messages = $this->messages["$locale"];
39  if (!is_string($key) || !isset($messages[$key]) || !is_string($messages[$key])) {
40  return null;
41  }
42 
43  return new SprintfMessageTemplate($messages[$key]);
44  }
45 }
elgg page messages
Definition: admin.css.php:233
WARNING: API IN FLUX.
Definition: Locale.php:13
$key
Definition: summary.php:34
__construct(array $messages)
Constructor.
WARNING: API IN FLUX.