aboutsummaryrefslogtreecommitdiff
path: root/lib/classes/JsonApi/Routes/RangeTree/InstituteOfRangeTreeNode.php
blob: 6ecf52a6033f6d5275872251b935fe3b45b300bc (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
<?php

namespace JsonApi\Routes\RangeTree;

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;
use JsonApi\Schemas\Institute as InstituteSchema;

class InstituteOfRangeTreeNode extends JsonApiController
{
    protected $allowedIncludePaths = [
        InstituteSchema::REL_STATUS_GROUPS,
    ];

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

        return $this->getContentResponse($node->institute);
    }
}