Ejemplo n.º 1
0
 /**
  * Generate the message blob for a given module in a given language.
  *
  * @param ResourceLoaderModule $module
  * @param string $lang Language code
  * @return string JSON blob
  */
 private function generateMessageBlob(ResourceLoaderModule $module, $lang)
 {
     $messages = [];
     foreach ($module->getMessages() as $key) {
         $messages[$key] = $this->fetchMessage($key, $lang);
     }
     $json = FormatJson::encode((object) $messages);
     if ($json === false) {
         $this->logger->warning('Failed to encode message blob for {module} ({lang})', ['module' => $module->getName(), 'lang' => $lang]);
         $json = '{}';
     }
     return $json;
 }
Ejemplo n.º 2
0
 /**
  * Get the message blob for a module
  *
  * @since 1.27
  * @param ResourceLoaderModule $module
  * @param string $lang Language code
  * @return string JSON
  */
 public function getBlob(ResourceLoaderModule $module, $lang)
 {
     $blobs = $this->getBlobs(array($module->getName() => $module), $lang);
     return $blobs[$module->getName()];
 }