blob: 05353cbbbb2f4339980deee1792fa60f62155bd3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
<?php
namespace JsonApi\Routes\Avatar;
use JsonApi\Errors\AuthorizationFailedException;
use JsonApi\Errors\RecordNotFoundException;
use JsonApi\JsonApiController;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
/**
* Delete one Avatar.
*/
class AvatarofRangeDelete extends JsonApiController
{
use AvatarHelpers;
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function __invoke(Request $request, Response $response, $args)
{
$range_id = $args['id'];
$range_type = $args['type'];
$user = $this->getUser($request);
['class' => $class, 'has_perm' => $has_perm] = self::getAvatarClass($range_id, $range_type, $user);
if (!$has_perm) {
throw new AuthorizationFailedException();
}
$class::getAvatar($range_id)->reset();
return $this->getCodeResponse(204);
}
}
|