mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -06:00
#4316 module on/off options
This commit is contained in:
parent
256f52c5ac
commit
0c1fb51db0
@ -16,6 +16,7 @@ return [
|
||||
'free_currencyconverterapi_key',
|
||||
'hide_price_categories',
|
||||
'tcmb_exchange_url',
|
||||
'enabled_modules',
|
||||
'enabled_currencies',
|
||||
'disable_sentry',
|
||||
'hide_ad_cat',
|
||||
|
||||
@ -194,6 +194,22 @@ return [
|
||||
},
|
||||
],
|
||||
],
|
||||
'enabled_modules' => [
|
||||
'type' => 'anomaly.field_type.checkboxes',
|
||||
'config' => [
|
||||
'mode' => 'tags',
|
||||
'default_value' => function () {
|
||||
$addons = app('module.collection')->enabled()->pluck('namespace')->all();
|
||||
|
||||
return $addons;
|
||||
},
|
||||
'options' => function () {
|
||||
$addons = app('module.collection')->pluck('namespace', 'namespace');
|
||||
|
||||
return $addons;
|
||||
},
|
||||
],
|
||||
],
|
||||
'market_place' => [
|
||||
'type' => 'anomaly.field_type.boolean',
|
||||
'config' => [
|
||||
|
||||
@ -125,6 +125,10 @@ return [
|
||||
'enabled_currencies' => [
|
||||
'name' => 'Enabled Currencies',
|
||||
],
|
||||
'enabled_modules' => [
|
||||
'name' => 'Enabled Modules',
|
||||
'warning' => 'Change at your own risk.',
|
||||
],
|
||||
'google_statistic_code' => [
|
||||
'name' => 'Google Statistic Code',
|
||||
],
|
||||
@ -133,8 +137,8 @@ return [
|
||||
],
|
||||
'market_place' => [
|
||||
'name' => 'Market Place',
|
||||
'instructions' => 'If the marketplace is down, your site will act as ecommerce. For example,
|
||||
some fields in the profile such as ads, dopings, messages, sale, packages and store are not visible and
|
||||
'instructions' => 'If the marketplace is down, your site will act as ecommerce. For example,
|
||||
some fields in the profile such as ads, dopings, messages, sale, packages and store are not visible and
|
||||
removes corporate membership.'
|
||||
],
|
||||
'price_area_hidden' => [
|
||||
|
||||
@ -2,11 +2,13 @@
|
||||
|
||||
use Anomaly\Streams\Platform\Addon\AddonServiceProvider;
|
||||
use Anomaly\Streams\Platform\Ui\ControlPanel\Component\Navigation\Event\SortNavigation;
|
||||
use Anomaly\Streams\Platform\Ui\Form\Event\FormWasSaved;
|
||||
use Anomaly\Streams\Platform\Ui\Table\Event\TableIsQuerying;
|
||||
use Illuminate\Pagination\AbstractPaginator;
|
||||
use Visiosoft\DefaultadminTheme\Listener\AddGsmFilter;
|
||||
use Visiosoft\DefaultadminTheme\Listener\AddViewAdsButton;
|
||||
use Visiosoft\DefaultadminTheme\Listener\ApplySorting;
|
||||
use Visiosoft\DefaultadminTheme\Listener\CheckEnabledModules;
|
||||
|
||||
/**
|
||||
* Class DefaultadminThemeServiceProvider
|
||||
@ -23,7 +25,10 @@ class DefaultadminThemeServiceProvider extends AddonServiceProvider
|
||||
],
|
||||
TableIsQuerying::class => [
|
||||
AddGsmFilter::class,
|
||||
AddViewAdsButton::class
|
||||
AddViewAdsButton::class,
|
||||
],
|
||||
FormWasSaved::class => [
|
||||
CheckEnabledModules::class,
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
@ -0,0 +1,41 @@
|
||||
<?php namespace Visiosoft\DefaultadminTheme\Listener;
|
||||
|
||||
use Anomaly\SettingsModule\Setting\Form\SettingFormBuilder;
|
||||
use Anomaly\Streams\Platform\Addon\Module\Command\InstallModule;
|
||||
use Anomaly\Streams\Platform\Addon\Module\Command\UninstallModule;
|
||||
use Anomaly\Streams\Platform\Addon\Module\Contract\ModuleRepositoryInterface;
|
||||
use Anomaly\Streams\Platform\Ui\Form\Event\FormWasSaved;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
|
||||
class CheckEnabledModules
|
||||
{
|
||||
use DispatchesJobs;
|
||||
|
||||
private $moduleRepository;
|
||||
|
||||
public function __construct(ModuleRepositoryInterface $moduleRepository)
|
||||
{
|
||||
$this->moduleRepository = $moduleRepository;
|
||||
}
|
||||
|
||||
public function handle(FormWasSaved $event)
|
||||
{
|
||||
$builder = $event->getBuilder();
|
||||
|
||||
if (get_class($builder) == SettingFormBuilder::class) {
|
||||
$value = $builder->getFormFields()->where('field', 'enabled_modules')->first()->getValue();
|
||||
$disabledModules = app('module.collection')->whereNotIn('namespace', $value);
|
||||
$enabledModules = app('module.collection')->whereIn('namespace', $value);
|
||||
foreach ($disabledModules as $module) {
|
||||
if ($module->isInstalled()) {
|
||||
$this->dispatchNow(new UninstallModule($module, true));
|
||||
}
|
||||
}
|
||||
foreach ($enabledModules as $module) {
|
||||
if (!$module->isInstalled()) {
|
||||
$this->dispatchNow(new InstallModule($module, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user