Move events to Flarum\Settings\Event namespace

This commit is contained in:
Franz Liedke 2017-06-24 13:16:02 +02:00
parent 564ea8ff73
commit 551e76f296
No known key found for this signature in database
GPG Key ID: 9A0231A879B055F4
7 changed files with 16 additions and 16 deletions

View File

@ -13,7 +13,7 @@ namespace Flarum\Admin;
use Flarum\Event\ExtensionWasDisabled;
use Flarum\Event\ExtensionWasEnabled;
use Flarum\Event\SettingWasSet;
use Flarum\Settings\Event\Saved;
use Flarum\Foundation\AbstractServiceProvider;
use Flarum\Http\Handler\RouteHandlerFactory;
use Flarum\Http\RouteCollection;
@ -63,7 +63,7 @@ class AdminServiceProvider extends AbstractServiceProvider
protected function flushWebAppAssetsWhenThemeChanged()
{
$this->app->make('events')->listen(SettingWasSet::class, function (SettingWasSet $event) {
$this->app->make('events')->listen(Saved::class, function (Saved $event) {
if (preg_match('/^theme_|^custom_less$/i', $event->key)) {
$this->getWebAppAssets()->flushCss();
}

View File

@ -13,7 +13,7 @@ namespace Flarum\Admin\Controller;
use Flarum\Admin\Frontend;
use Flarum\Core\Permission;
use Flarum\Event\PrepareUnserializedSettings;
use Flarum\Settings\Event\Deserializing;
use Flarum\Extension\ExtensionManager;
use Flarum\Frontend\AbstractFrontendController;
use Flarum\Settings\SettingsRepositoryInterface;
@ -56,7 +56,7 @@ class FrontendController extends AbstractFrontendController
$settings = $this->settings->all();
$this->events->fire(
new PrepareUnserializedSettings($settings)
new Deserializing($settings)
);
$view->setVariable('settings', $settings);

View File

@ -12,8 +12,8 @@
namespace Flarum\Api\Controller;
use Flarum\Core\Access\AssertPermissionTrait;
use Flarum\Event\PrepareSerializedSetting;
use Flarum\Event\SettingWasSet;
use Flarum\Settings\Event\Serializing;
use Flarum\Settings\Event\Saved;
use Flarum\Http\Controller\ControllerInterface;
use Flarum\Settings\SettingsRepositoryInterface;
use Illuminate\Contracts\Events\Dispatcher;
@ -53,11 +53,11 @@ class SetSettingsController implements ControllerInterface
$settings = $request->getParsedBody();
foreach ($settings as $k => $v) {
$this->dispatcher->fire(new PrepareSerializedSetting($k, $v));
$this->dispatcher->fire(new Serializing($k, $v));
$this->settings->set($k, $v);
$this->dispatcher->fire(new SettingWasSet($k, $v));
$this->dispatcher->fire(new Saved($k, $v));
}
return new EmptyResponse(204);

View File

@ -14,7 +14,7 @@ namespace Flarum\Forum;
use Flarum\Event\ConfigureForumRoutes;
use Flarum\Event\ExtensionWasDisabled;
use Flarum\Event\ExtensionWasEnabled;
use Flarum\Event\SettingWasSet;
use Flarum\Settings\Event\Saved;
use Flarum\Foundation\AbstractServiceProvider;
use Flarum\Http\Handler\RouteHandlerFactory;
use Flarum\Http\RouteCollection;
@ -82,7 +82,7 @@ class ForumServiceProvider extends AbstractServiceProvider
protected function flushWebAppAssetsWhenThemeChanged()
{
$this->app->make('events')->listen(SettingWasSet::class, function (SettingWasSet $event) {
$this->app->make('events')->listen(Saved::class, function (Saved $event) {
if (preg_match('/^theme_|^custom_less$/i', $event->key)) {
$this->getWebAppAssets()->flushCss();
}

View File

@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
namespace Flarum\Event;
namespace Flarum\Settings\Event;
/**
* Prepare settings for display in the client.
@ -17,7 +17,7 @@ namespace Flarum\Event;
* This event is fired when settings have been retrieved from the database and
* are being unserialized for display in the client.
*/
class PrepareUnserializedSettings
class Deserializing
{
/**
* The settings array to be unserialized.

View File

@ -9,9 +9,9 @@
* file that was distributed with this source code.
*/
namespace Flarum\Event;
namespace Flarum\Settings\Event;
class SettingWasSet
class Saved
{
/**
* The setting key that was set.

View File

@ -9,9 +9,9 @@
* file that was distributed with this source code.
*/
namespace Flarum\Event;
namespace Flarum\Settings\Event;
class PrepareSerializedSetting
class Serializing
{
/**
* The settings key being saved.