Throw exception when two plugins use the same name definition

This commit is contained in:
printempw 2017-07-30 16:11:14 +08:00
parent beb4b08f88
commit 0566d4e7e0
3 changed files with 14 additions and 0 deletions

View File

@ -7,6 +7,7 @@ use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use App\Events\PluginWasUninstalled;
use Illuminate\Filesystem\Filesystem;
use App\Exceptions\PrettyPageException;
use Illuminate\Contracts\Events\Dispatcher;
use App\Services\Repositories\OptionRepository;
use Illuminate\Contracts\Foundation\Application;
@ -90,6 +91,13 @@ class PluginManager
$plugin->setVersion(Arr::get($package, 'version'));
$plugin->setEnabled($this->isEnabled($plugin->name));
if ($plugins->has($plugin->name)) {
throw new PrettyPageException(trans('errors.plugins.duplicate', [
'dir1' => $plugin->getDirname(),
'dir2' => $plugins->get($plugin->name)->getDirname()
]), 5);
}
$plugins->put($plugin->name, $plugin);
}

View File

@ -11,3 +11,6 @@ exception:
detail: 'Details: :msg'
message: |
Whoops, looks like something went wrong. (enable APP_DEBUG in .env to see details)
plugins:
duplicate: The plugin [:dir1] has a duplicated plugin name definition which is same to plugin [:dir2]. Please check your plugins directory, remove one of them or use another name definition.

View File

@ -12,3 +12,6 @@ exception:
message: |
如果您是访客,这说明网站程序出现了一些错误,请您稍后再试或联系站长。
如果您是站长,请开启 .env 中的 APP_DEBUG 以查看详细信息。
plugins:
duplicate: 【插件定义重复】:dir1 目录下的插件与 :dir2 目录下的插件使用了相同的 name 定义并造成了冲突。请检查您的 plugins 目录,移除其中一个插件或者使用不同的 name 属性。