Fixed disabled plugin for home module.
This commit is contained in:
parent
c66ef7738a
commit
b023ee7a1c
|
|
@ -16,6 +16,7 @@ use Illuminate\Filesystem\Filesystem;
|
||||||
use Illuminate\Http\UploadedFile;
|
use Illuminate\Http\UploadedFile;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use ZanySoft\Zip\Zip;
|
use ZanySoft\Zip\Zip;
|
||||||
|
|
||||||
class Manager
|
class Manager
|
||||||
|
|
@ -113,6 +114,7 @@ class Manager
|
||||||
*/
|
*/
|
||||||
public function getPlugin($code): ?Plugin
|
public function getPlugin($code): ?Plugin
|
||||||
{
|
{
|
||||||
|
$code = Str::snake($code);
|
||||||
$plugins = $this->getPlugins();
|
$plugins = $this->getPlugins();
|
||||||
|
|
||||||
return $plugins[$code] ?? null;
|
return $plugins[$code] ?? null;
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ use Beike\Shop\Services\TotalServices\ShippingService;
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Illuminate\Support\Facades\Artisan;
|
use Illuminate\Support\Facades\Artisan;
|
||||||
use Illuminate\Support\Facades\File;
|
use Illuminate\Support\Facades\File;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class PluginRepo
|
class PluginRepo
|
||||||
{
|
{
|
||||||
|
|
@ -113,6 +114,20 @@ class PluginRepo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get plugin by code
|
||||||
|
*
|
||||||
|
* @param $code
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function getPlugin($code): mixed
|
||||||
|
{
|
||||||
|
$code = Str::camel($code);
|
||||||
|
$plugins = self::getPluginsByCode();
|
||||||
|
|
||||||
|
return $plugins->get($code);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断插件是否安装
|
* 判断插件是否安装
|
||||||
*
|
*
|
||||||
|
|
@ -126,6 +141,19 @@ class PluginRepo
|
||||||
return $plugins->has($code);
|
return $plugins->has($code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断插件是否安装
|
||||||
|
*
|
||||||
|
* @param $code
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function enabled($code): bool
|
||||||
|
{
|
||||||
|
$code = Str::camel($code);
|
||||||
|
|
||||||
|
return SettingRepo::getPluginStatus($code);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取所有已安装插件列表
|
* 获取所有已安装插件列表
|
||||||
*
|
*
|
||||||
|
|
@ -144,7 +172,7 @@ class PluginRepo
|
||||||
* 获取所有已安装插件
|
* 获取所有已安装插件
|
||||||
* @return Plugin[]|Collection
|
* @return Plugin[]|Collection
|
||||||
*/
|
*/
|
||||||
public static function getPluginsByCode()
|
public static function getPluginsByCode(): Collection|array
|
||||||
{
|
{
|
||||||
$allPlugins = self::allPlugins();
|
$allPlugins = self::allPlugins();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,15 @@ class HomeController extends Controller
|
||||||
$viewPath = "design.{$code}";
|
$viewPath = "design.{$code}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$paths = explode('::', $viewPath);
|
||||||
|
if (count($paths) == 2) {
|
||||||
|
$pluginCode = $paths[0];
|
||||||
|
$plugin = app('plugin')->getPlugin($pluginCode);
|
||||||
|
if (! $plugin || ! $plugin->getEnabled()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (view()->exists($viewPath) && $moduleId) {
|
if (view()->exists($viewPath) && $moduleId) {
|
||||||
$moduleItems[] = [
|
$moduleItems[] = [
|
||||||
'code' => $code,
|
'code' => $code,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue