45 lines
947 B
PHP
45 lines
947 B
PHP
<?php
|
|
namespace Szurubooru\Routes\Scores;
|
|
use Szurubooru\Entities\Entity;
|
|
use Szurubooru\Helpers\InputReader;
|
|
use Szurubooru\Services\AuthService;
|
|
use Szurubooru\Services\PostService;
|
|
use Szurubooru\Services\PrivilegeService;
|
|
use Szurubooru\Services\ScoreService;
|
|
|
|
class SetPostScore extends AbstractScoreRoute
|
|
{
|
|
private $postService;
|
|
|
|
public function __construct(
|
|
PrivilegeService $privilegeService,
|
|
AuthService $authService,
|
|
PostService $postService,
|
|
ScoreService $scoreService,
|
|
InputReader $inputReader)
|
|
{
|
|
parent::__construct(
|
|
$authService,
|
|
$inputReader,
|
|
$privilegeService,
|
|
$scoreService);
|
|
|
|
$this->postService = $postService;
|
|
}
|
|
|
|
public function getMethods()
|
|
{
|
|
return ['POST', 'PUT'];
|
|
}
|
|
|
|
public function getUrl()
|
|
{
|
|
return '/api/posts/:postNameOrId/score';
|
|
}
|
|
|
|
public function work()
|
|
{
|
|
$post = $this->postService->getByNameOrId($this->getArgument('postNameOrId'));
|
|
return $this->setScore($post);
|
|
}
|
|
}
|