Optimize plugin manager
This commit is contained in:
parent
b023ee7a1c
commit
873954614a
|
|
@ -136,6 +136,23 @@ class Manager
|
|||
return $plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check plugin is active, include existed, installed and enabled
|
||||
*
|
||||
* @param $code
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function checkActive($code): bool
|
||||
{
|
||||
$plugin = $this->getPlugin($code);
|
||||
if (empty($plugin) || ! $plugin->getInstalled() || ! $plugin->getEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取插件目录以及配置
|
||||
*
|
||||
|
|
|
|||
|
|
@ -32,8 +32,7 @@ class HomeController extends Controller
|
|||
$paths = explode('::', $viewPath);
|
||||
if (count($paths) == 2) {
|
||||
$pluginCode = $paths[0];
|
||||
$plugin = app('plugin')->getPlugin($pluginCode);
|
||||
if (! $plugin || ! $plugin->getEnabled()) {
|
||||
if (! app('plugin')->checkActive($pluginCode)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,8 +33,7 @@ class ShippingService
|
|||
$shippingPluginCode = self::parseShippingPluginCode($shippingMethod);
|
||||
$pluginCode = Str::studly($shippingPluginCode);
|
||||
|
||||
$plugin = app('plugin')->getPlugin($shippingPluginCode);
|
||||
if (empty($plugin) || ! $plugin->getInstalled() || ! $plugin->getEnabled()) {
|
||||
if (! app('plugin')->checkActive($shippingPluginCode)) {
|
||||
$cart = $checkout->cart;
|
||||
$cart->shipping_method_code = '';
|
||||
$cart->saveOrFail();
|
||||
|
|
|
|||
Loading…
Reference in New Issue