mirror of
https://github.com/flarum/framework.git
synced 2025-02-21 09:53:27 +08:00
Performance: Cache translation catalogue to avoid reparsing YAML
This commit is contained in:
parent
99686ef8bb
commit
89a43d1adf
@ -46,6 +46,7 @@
|
||||
"nikic/fast-route": "^0.6",
|
||||
"oyejorge/less.php": "~1.5",
|
||||
"psr/http-message": "^1.0",
|
||||
"symfony/config": "^2.7",
|
||||
"symfony/console": "^2.7",
|
||||
"symfony/http-foundation": "^2.7",
|
||||
"symfony/translation": "^2.7",
|
||||
|
@ -14,35 +14,43 @@ namespace Flarum\Debug\Console;
|
||||
use Flarum\Admin\WebApp as AdminWebApp;
|
||||
use Flarum\Console\Command\AbstractCommand;
|
||||
use Flarum\Forum\WebApp as ForumWebApp;
|
||||
use Flarum\Foundation\Application;
|
||||
use Illuminate\Contracts\Cache\Store;
|
||||
|
||||
class CacheClearCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Cache\Store
|
||||
* @var Store
|
||||
*/
|
||||
protected $cache;
|
||||
|
||||
/**
|
||||
* @var \Flarum\Forum\WebApp
|
||||
* @var ForumWebApp
|
||||
*/
|
||||
protected $forum;
|
||||
|
||||
/**
|
||||
* @var \Flarum\Admin\WebApp
|
||||
* @var AdminWebApp
|
||||
*/
|
||||
protected $admin;
|
||||
|
||||
/**
|
||||
* @var Application
|
||||
*/
|
||||
protected $app;
|
||||
|
||||
/**
|
||||
* @param Store $cache
|
||||
* @param ForumWebApp $forum
|
||||
* @param AdminWebApp $admin
|
||||
* @param Application $app
|
||||
*/
|
||||
public function __construct(Store $cache, ForumWebApp $forum, AdminWebApp $admin)
|
||||
public function __construct(Store $cache, ForumWebApp $forum, AdminWebApp $admin, Application $app)
|
||||
{
|
||||
$this->cache = $cache;
|
||||
$this->forum = $forum;
|
||||
$this->admin = $admin;
|
||||
$this->app = $app;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
@ -68,5 +76,9 @@ class CacheClearCommand extends AbstractCommand
|
||||
$this->admin->getAssets()->flush();
|
||||
|
||||
$this->cache->flush();
|
||||
|
||||
$storagePath = $this->app->storagePath();
|
||||
array_map('unlink', glob($storagePath.'/formatter/*'));
|
||||
array_map('unlink', glob($storagePath.'/locale/*'));
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class LocaleServiceProvider extends AbstractServiceProvider
|
||||
$this->app->singleton('translator', function () {
|
||||
$defaultLocale = $this->getDefaultLocale();
|
||||
|
||||
$translator = new Translator($defaultLocale, new MessageSelector());
|
||||
$translator = new Translator($defaultLocale, null, $this->app->storagePath().'/locale', $this->app->inDebugMode());
|
||||
$translator->setFallbackLocales([$defaultLocale, 'en']);
|
||||
$translator->addLoader('prefixed_yaml', new PrefixedYamlFileLoader());
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user