private function assertMessagesJsonEquals(array $expectedMessages) { $messagesJson = CachingService::getMessagesJson(); $this->assertJson($messagesJson); $messages = json_decode($messagesJson, true); $this->assertEquals($expectedMessages, $messages); }
/** * Execute the console command. * * @return void */ public function fire() { $this->line('Refreshing the message cache...'); $locales = Config::get('js-localization::config.locales'); if (!is_array($locales)) { throw new \Exception('Please set the "locales" config! See https://github.com/andywer/laravel-js-localization#configuration'); } CachingService::refreshMessageCache(); }
public function createJsMessages() { $messages = CachingService::getMessagesJson(); $messages = $this->ensureBackwardsCompatibility($messages); $contents = 'Lang.addMessages(' . $messages . ');'; $contents .= 'Lang.setLocale("' . Lang::locale() . '");'; $lastModified = new DateTime(); $lastModified->setTimestamp(CachingService::getLastRefreshTimestamp()); return Response::make($contents)->header('Content-Type', 'text/javascript')->setLastModified($lastModified); }