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