Dispatch the Deserializing event in Admin Content (#1532)

* Dispatch the Deserializing event

* Apply fixes from StyleCI (#1)
This commit is contained in:
Charlie 2018-08-11 00:45:11 -07:00 committed by Toby Zerner
parent 24fd2f32c7
commit ef9ed7f4fa

View File

@ -15,7 +15,9 @@ use Flarum\Extension\ExtensionManager;
use Flarum\Frontend\Content\ContentInterface;
use Flarum\Frontend\HtmlDocument;
use Flarum\Group\Permission;
use Flarum\Settings\Event\Deserializing;
use Flarum\Settings\SettingsRepositoryInterface;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Database\ConnectionInterface;
use Psr\Http\Message\ServerRequestInterface as Request;
@ -40,17 +42,25 @@ class AdminPayload implements ContentInterface
* @param SettingsRepositoryInterface $settings
* @param ExtensionManager $extensions
* @param ConnectionInterface $db
* @param Dispatcher $events
*/
public function __construct(SettingsRepositoryInterface $settings, ExtensionManager $extensions, ConnectionInterface $db)
public function __construct(SettingsRepositoryInterface $settings, ExtensionManager $extensions, ConnectionInterface $db, Dispatcher $events)
{
$this->settings = $settings;
$this->extensions = $extensions;
$this->db = $db;
$this->events = $events;
}
public function populate(HtmlDocument $document, Request $request)
{
$document->payload['settings'] = $this->settings->all();
$settings = $this->settings->all();
$this->events->dispatch(
new Deserializing($settings)
);
$document->payload['settings'] = $settings;
$document->payload['permissions'] = Permission::map();
$document->payload['extensions'] = $this->extensions->getExtensions()->toArray();