mirror of
https://github.com/flarum/core.git
synced 2025-07-28 12:10:51 +02:00
Flush the embed client assets when settings are changed
This commit is contained in:
@@ -14,4 +14,5 @@ use Illuminate\Contracts\Events\Dispatcher;
|
|||||||
|
|
||||||
return function (Dispatcher $events) {
|
return function (Dispatcher $events) {
|
||||||
$events->subscribe(Listener\AddEmbedRoute::class);
|
$events->subscribe(Listener\AddEmbedRoute::class);
|
||||||
};
|
$events->subscribe(Listener\FlushEmbedAssetsWhenSettingsAreChanged::class);
|
||||||
|
};
|
||||||
|
@@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* This file is part of Flarum.
|
||||||
|
*
|
||||||
|
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Flarum\Embed\Listener;
|
||||||
|
|
||||||
|
use Flarum\Embed\DiscussionController;
|
||||||
|
use Flarum\Event\ExtensionWasDisabled;
|
||||||
|
use Flarum\Event\ExtensionWasEnabled;
|
||||||
|
use Flarum\Event\SettingWasSet;
|
||||||
|
use Illuminate\Contracts\Events\Dispatcher;
|
||||||
|
|
||||||
|
class FlushEmbedAssetsWhenSettingsAreChanged
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var DiscussionController
|
||||||
|
*/
|
||||||
|
protected $controller;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param DiscussionController $controller
|
||||||
|
*/
|
||||||
|
public function __construct(DiscussionController $controller)
|
||||||
|
{
|
||||||
|
$this->controller = $controller;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Dispatcher $events
|
||||||
|
*/
|
||||||
|
public function subscribe(Dispatcher $events)
|
||||||
|
{
|
||||||
|
$events->listen(SettingWasSet::class, [$this, 'flushCss']);
|
||||||
|
$events->listen(ExtensionWasEnabled::class, [$this, 'flushAssets']);
|
||||||
|
$events->listen(ExtensionWasDisabled::class, [$this, 'flushAssets']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param SettingWasSet $event
|
||||||
|
*/
|
||||||
|
public function flushCss(SettingWasSet $event)
|
||||||
|
{
|
||||||
|
if (preg_match('/^theme_|^custom_less$/i', $event->key)) {
|
||||||
|
$this->controller->flushCss();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function flushAssets()
|
||||||
|
{
|
||||||
|
$this->controller->flushAssets();
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user