aboutsummaryrefslogtreecommitdiff
path: root/lib/classes/JsonApi/Routes/StudyAreas/InstituteOfStudyAreas.php
blob: ede0c7419258d37a6be927f1ff1c2afe592d22a9 (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\StudyAreas;

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 InstituteOfStudyAreas extends JsonApiController
{
    protected $allowedIncludePaths = [
        InstituteSchema::REL_STATUS_GROUPS,
    ];

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

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