diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 9c63904b..0f519526 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -30,6 +30,7 @@ class Kernel extends HttpKernel \Illuminate\Session\Middleware\StartSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class, \App\Http\Middleware\Internationalization::class, + \App\Http\Middleware\SaveOptionRepository::class, //\App\Http\Middleware\VerifyCsrfToken::class, ], diff --git a/app/Http/Middleware/SaveOptionRepository.php b/app/Http/Middleware/SaveOptionRepository.php new file mode 100644 index 00000000..32da3e70 --- /dev/null +++ b/app/Http/Middleware/SaveOptionRepository.php @@ -0,0 +1,32 @@ +save(); + } +} diff --git a/app/Services/PluginManager.php b/app/Services/PluginManager.php index 468adc93..4d4a1e47 100644 --- a/app/Services/PluginManager.php +++ b/app/Services/PluginManager.php @@ -223,6 +223,9 @@ class PluginManager $enabled = array_values(array_unique($enabled)); $this->option->set('plugins_enabled', json_encode($enabled)); + + // ensure to save options + $this->option->save(); } /** diff --git a/app/Services/Repositories/OptionRepository.php b/app/Services/Repositories/OptionRepository.php index 190dd954..efbe7225 100644 --- a/app/Services/Repositories/OptionRepository.php +++ b/app/Services/Repositories/OptionRepository.php @@ -71,10 +71,10 @@ class OptionRepository extends Repository */ public function save() { - $this->items_modified = array_unique($this->items_modified); + $this->itemsModified = array_unique($this->itemsModified); try { - foreach ($this->items_modified as $key) { + foreach ($this->itemsModified as $key) { if (!DB::table('options')->where('option_name', $key)->first()) { DB::table('options') ->insert(['option_name' => $key, 'option_value' => $this[$key]]); @@ -84,6 +84,9 @@ class OptionRepository extends Repository ->update(['option_value' => $this[$key]]); } } + + // clear the list + $this->itemsModified = []; } catch (QueryException $e) { return; } diff --git a/app/Services/Repositories/Repository.php b/app/Services/Repositories/Repository.php index b1bd7f1a..e7f4b8bd 100644 --- a/app/Services/Repositories/Repository.php +++ b/app/Services/Repositories/Repository.php @@ -19,7 +19,7 @@ class Repository implements ArrayAccess // Illuminate\Contracts\Cache\Repository * * @var array */ - protected $items_modified = []; + protected $itemsModified = []; /** * Determine if an item exists in the repository. @@ -57,11 +57,11 @@ class Repository implements ArrayAccess // Illuminate\Contracts\Cache\Repository // If given key is an array foreach ($key as $innerKey => $innerValue) { Arr::set($this->items, $innerKey, $innerValue); - $this->items_modified[] = $innerKey; + $this->itemsModified[] = $innerKey; } } else { Arr::set($this->items, $key, $value); - $this->items_modified[] = $key; + $this->itemsModified[] = $key; } } diff --git a/bootstrap/app.php b/bootstrap/app.php new file mode 100644 index 00000000..f2801adf --- /dev/null +++ b/bootstrap/app.php @@ -0,0 +1,55 @@ +singleton( + Illuminate\Contracts\Http\Kernel::class, + App\Http\Kernel::class +); + +$app->singleton( + Illuminate\Contracts\Console\Kernel::class, + App\Console\Kernel::class +); + +$app->singleton( + Illuminate\Contracts\Debug\ExceptionHandler::class, + App\Exceptions\Handler::class +); + +/* +|-------------------------------------------------------------------------- +| Return The Application +|-------------------------------------------------------------------------- +| +| This script returns the application instance. The instance is given to +| the calling script so we can separate the building of the instances +| from the actual running of the application and sending responses. +| +*/ + +return $app; diff --git a/bootstrap/handler.php b/bootstrap/handler.php index 3afc5e13..751adb7a 100644 --- a/bootstrap/handler.php +++ b/bootstrap/handler.php @@ -6,53 +6,14 @@ |-------------------------------------------------------------------------- | | Blessing Skin Server separated these codes here to ensure that -| runtime check will be executed correctly, since namespaced class names -| will be regarded as parse error under PHP 5.3. +| runtime check at index.php will be executed correctly, since +| namespaced class names will cause parse error under PHP 5.3. | */ require __DIR__.'/autoload.php'; -/* -|-------------------------------------------------------------------------- -| Create The Application -|-------------------------------------------------------------------------- -| -| The first thing we will do is create a new Laravel application instance -| which serves as the "glue" for all the components of Laravel, and is -| the IoC container for the system binding all of the various parts. -| -*/ - -$app = new Illuminate\Foundation\Application( - realpath(__DIR__.'/../') -); - -/* -|-------------------------------------------------------------------------- -| Bind Important Interfaces -|-------------------------------------------------------------------------- -| -| Next, we need to bind some important interfaces into the container so -| we will be able to resolve them when needed. The kernels serve the -| incoming requests to this application from both the web and CLI. -| -*/ - -$app->singleton( - Illuminate\Contracts\Http\Kernel::class, - App\Http\Kernel::class -); - -$app->singleton( - Illuminate\Contracts\Console\Kernel::class, - App\Console\Kernel::class -); - -$app->singleton( - Illuminate\Contracts\Debug\ExceptionHandler::class, - App\Exceptions\Handler::class -); +$app = require_once __DIR__.'/app.php'; $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);