add support for using trans id in plugin title/description

This commit is contained in:
printempw 2017-01-02 10:39:50 +08:00
parent cc6afebfec
commit 2125e05bc2
3 changed files with 15 additions and 7 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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);
}
}