mirror of
https://github.com/flarum/framework.git
synced 2025-02-16 01:22:46 +08:00
65 lines
1.5 KiB
PHP
65 lines
1.5 KiB
PHP
<?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\Core\Access\AssertPermissionTrait;
|
|
use Flarum\Foundation\Application;
|
|
use Flarum\Settings\SettingsRepositoryInterface;
|
|
use League\Flysystem\Adapter\Local;
|
|
use League\Flysystem\Filesystem;
|
|
use Psr\Http\Message\ServerRequestInterface;
|
|
use Zend\Diactoros\Response\EmptyResponse;
|
|
|
|
class DeleteLogoController extends AbstractDeleteController
|
|
{
|
|
use AssertPermissionTrait;
|
|
|
|
/**
|
|
* @var SettingsRepositoryInterface
|
|
*/
|
|
protected $settings;
|
|
|
|
/**
|
|
* @var Application
|
|
*/
|
|
protected $app;
|
|
|
|
/**
|
|
* @param SettingsRepositoryInterface $settings
|
|
*/
|
|
public function __construct(SettingsRepositoryInterface $settings, Application $app)
|
|
{
|
|
$this->settings = $settings;
|
|
$this->app = $app;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
protected function delete(ServerRequestInterface $request)
|
|
{
|
|
$this->assertAdmin($request->getAttribute('actor'));
|
|
|
|
$path = $this->settings->get('logo_path');
|
|
|
|
$this->settings->set('logo_path', null);
|
|
|
|
$uploadDir = new Filesystem(new Local($this->app->publicPath().'/assets'));
|
|
|
|
if ($uploadDir->has($path)) {
|
|
$uploadDir->delete($path);
|
|
}
|
|
|
|
return new EmptyResponse(204);
|
|
}
|
|
}
|