SKevo
# extend.php
<?php
namespace YourNamespace;
use Flarum\Extend;
return [
(new Extend\Event())
->subscribe(CustomSubscriber::class)
];
# CustomSubscriber.php
<?php
namespace YourNamespace;
use Flarum\Extension\Event\Disabling;
use Flarum\Extension\Event\Enabling;
use Flarum\Foundation\Console\CacheClearCommand;
use Illuminate\Contracts\Events\Dispatcher;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\NullOutput;
class CustomSubscriber
{
protected $command;
public function __construct(CacheClearCommand $command)
{
$this->command = $command;
}
public function subscribe(Dispatcher $events)
{
$events->listen([Enabling::class, Disabling::class], [$this, 'clearCache']);
}
public function clearCache($event)
{
/**
* Ref: https://github.com/flarum/core/blob/v0.1.0-beta.16/src/Api/Controller/ClearCacheController.php#L40-L43
*/
$this->command->run(
new ArrayInput([]),
new NullOutput()
);
}
}