mirror of
https://github.com/flarum/core.git
synced 2025-07-19 07:41:22 +02:00
Add "clear cache" button to admin
This commit is contained in:
56
src/Api/Controller/ClearCacheController.php
Normal file
56
src/Api/Controller/ClearCacheController.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?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\Api\Controller;
|
||||
|
||||
use Flarum\Foundation\Application;
|
||||
use Flarum\Foundation\Console\CacheClearCommand;
|
||||
use Flarum\Settings\SettingsRepositoryInterface;
|
||||
use Flarum\User\AssertPermissionTrait;
|
||||
use League\Flysystem\Adapter\Local;
|
||||
use League\Flysystem\Filesystem;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Output\NullOutput;
|
||||
use Zend\Diactoros\Response\EmptyResponse;
|
||||
|
||||
class ClearCacheController extends AbstractDeleteController
|
||||
{
|
||||
use AssertPermissionTrait;
|
||||
|
||||
/**
|
||||
* @var CacheClearCommand
|
||||
*/
|
||||
protected $command;
|
||||
|
||||
/**
|
||||
* @param CacheClearCommand $command
|
||||
*/
|
||||
public function __construct(CacheClearCommand $command)
|
||||
{
|
||||
$this->command = $command;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function delete(ServerRequestInterface $request)
|
||||
{
|
||||
$this->assertAdmin($request->getAttribute('actor'));
|
||||
|
||||
$this->command->run(
|
||||
new ArrayInput([]),
|
||||
new NullOutput()
|
||||
);
|
||||
|
||||
return new EmptyResponse(204);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user