From 2125e05bc25820942a72d7e7a955f4b025b3db4d Mon Sep 17 00:00:00 2001 From: printempw Date: Mon, 2 Jan 2017 10:39:50 +0800 Subject: [PATCH] add support for using trans id in plugin title/description --- app/Http/Controllers/PluginController.php | 4 ++++ app/Providers/PluginServiceProvider.php | 13 ++++++++----- app/helpers.php | 5 +++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/PluginController.php b/app/Http/Controllers/PluginController.php index 27408b34..e5182bd4 100644 --- a/app/Http/Controllers/PluginController.php +++ b/app/Http/Controllers/PluginController.php @@ -21,6 +21,10 @@ class PluginController extends Controller if ($plugins->getPlugins()->has($id)) { $plugin = $plugins->getPlugin($id); + + // pass the plugin title through the translator + $plugin->title = trans($plugin->title); + switch ($request->get('action')) { case 'enable': $plugins->enable($id); diff --git a/app/Providers/PluginServiceProvider.php b/app/Providers/PluginServiceProvider.php index 71c8824e..67a1c81a 100644 --- a/app/Providers/PluginServiceProvider.php +++ b/app/Providers/PluginServiceProvider.php @@ -22,12 +22,15 @@ class PluginServiceProvider extends ServiceProvider // make view instead of view.finder since the finder is defined as not a singleton $finder = $this->app->make('view'); - foreach ($plugins->getEnabledPlugins() as $plugin) { - $src_paths[$plugin->getNameSpace()] = $plugin->getPath()."/src"; - // add paths of translation files for namespace hints + foreach ($plugins->getPlugins() as $plugin) { + if ($plugin->isEnabled()) { + $src_paths[$plugin->getNameSpace()] = $plugin->getPath()."/src"; + // add paths of views + $finder->addNamespace($plugin->getNameSpace(), $plugin->getPath()."/views"); + } + + // always add paths of translation files for namespace hints $loader->addNamespace($plugin->getNameSpace(), $plugin->getPath()."/lang"); - // add paths of views - $finder->addNamespace($plugin->getNameSpace(), $plugin->getPath()."/views"); } $this->registerClassAutoloader($src_paths); diff --git a/app/helpers.php b/app/helpers.php index e7c4fa8f..ad41f4e6 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -253,9 +253,10 @@ if (! function_exists('option')) { * * @param array|string $key * @param mixed $default + * @param raw $raw return raw value without convertion * @return mixed */ - function option($key = null, $default = null) + function option($key = null, $default = null, $raw = false) { $options = app('options'); @@ -270,7 +271,7 @@ if (! function_exists('option')) { return; } - return $options->get($key, $default); + return $options->get($key, $default, $raw); } }