37 lines
783 B
PHP
37 lines
783 B
PHP
<?php
|
|
namespace Szurubooru\Routes\Posts;
|
|
use Szurubooru\Privilege;
|
|
use Szurubooru\Services\PostService;
|
|
use Szurubooru\Services\PrivilegeService;
|
|
|
|
class DeletePost extends AbstractPostRoute
|
|
{
|
|
private $privilegeService;
|
|
private $postService;
|
|
|
|
public function __construct(
|
|
PrivilegeService $privilegeService,
|
|
PostService $postService)
|
|
{
|
|
$this->privilegeService = $privilegeService;
|
|
$this->postService = $postService;
|
|
}
|
|
|
|
public function getMethods()
|
|
{
|
|
return ['DELETE'];
|
|
}
|
|
|
|
public function getUrl()
|
|
{
|
|
return '/api/posts/:postNameOrId';
|
|
}
|
|
|
|
public function work()
|
|
{
|
|
$this->privilegeService->assertPrivilege(Privilege::DELETE_POSTS);
|
|
|
|
$post = $this->postService->getByNameOrId($this->getArgument('postNameOrId'));
|
|
$this->postService->deletePost($post);
|
|
}
|
|
}
|