| Conditions | 4 |
| Paths | 6 |
| Total Lines | 21 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 31 | public function load($resource, $locale, $domain = 'messages') |
||
| 32 | { |
||
| 33 | $resource = $this->memcached; |
||
| 34 | $messagesOfDomain = $resource->getItem($locale); |
||
| 35 | // no messages in cache |
||
| 36 | if (!isset($messagesOfDomain[$domain])) { |
||
| 37 | $messages = array(); |
||
| 38 | } else { |
||
| 39 | $messages = $messagesOfDomain[$domain]; |
||
| 40 | } |
||
| 41 | if (!is_array($messages)) { |
||
| 42 | throw new InvalidResourceException(sprintf('The resource "%s" must contain an array.', $resource)); |
||
| 43 | } |
||
| 44 | $catalogue = new MessageCatalogue($locale); |
||
| 45 | foreach ($messages as $ymlKey => $translation) { |
||
| 46 | $catalogue->set($ymlKey, $translation, $domain); |
||
| 47 | } |
||
| 48 | $catalogue->addResource($resource); |
||
| 49 | |||
| 50 | return $catalogue; |
||
| 51 | } |
||
| 52 | } |
||
| 53 |