aboutsummaryrefslogtreecommitdiff
path: root/lib/classes/JsonApi/Routes/Mvv/ComponentVersionsShow.php
blob: 248cc696c5529883033360b7d3dbe7b1004b33b7 (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
<?php

namespace JsonApi\Routes\Mvv;

use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use JsonApi\Errors\AuthorizationFailedException;
use JsonApi\Errors\RecordNotFoundException;
use JsonApi\JsonApiController;

class ComponentVersionsShow extends JsonApiController
{
    /**
     * @SuppressWarnings(PHPMD.UnusedFormalParameters)
     */
    public function __invoke(Request $request, Response $response, $args)
    {
        $version = \StgteilVersion::find($args['id']);
        if (!$version) {
            throw new RecordNotFoundException();
        }

        if (!Authority::canShowComponentVersion($this->getUser($request), $version)) {
            throw new AuthorizationFailedException();
        }

        return $this->getContentResponse($version);
    }
}