Skip to content
Snippets Groups Projects
Select Git revision
  • 78afc3856fac8e52f6fa747dc4b79dc6556e449d
  • main default protected
  • studip-rector
  • ci-opt
  • course-members-export-as-word
  • data-vue-app
  • pipeline-improvements
  • webpack-optimizations
  • rector
  • icon-renewal
  • http-client-and-factories
  • jsonapi-atomic-operations
  • vueify-messages
  • tic-2341
  • 135-translatable-study-areas
  • extensible-sorm-action-parameters
  • sorm-configuration-trait
  • jsonapi-mvv-routes
  • docblocks-for-magic-methods
19 results

StatusgroupShow.php

Blame
  • Forked from Stud.IP / Stud.IP
    Source project has a limited visibility.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    StatusgroupShow.php 857 B
    <?php
    
    namespace JsonApi\Routes;
    
    use JsonApi\Errors\AuthorizationFailedException;
    use Psr\Http\Message\ResponseInterface as Response;
    use Psr\Http\Message\ServerRequestInterface as Request;
    use JsonApi\JsonApiController;
    use JsonApi\Errors\RecordNotFoundException;
    
    class StatusgroupShow extends JsonApiController
    {
        protected $allowedIncludePaths = [
            'range'
        ];
    
        public function __invoke(Request $request, Response $response, $args)
        {
            $group = \Statusgruppen::find($args['id']);
            if (!$group) {
                throw new RecordNotFoundException();
            }
    
            $user = $this->getUser($request);
            $range = $group->range;
    
            if ($range && !$range->isAccessibleToUser($user->id)) {
                throw new AuthorizationFailedException();
            }
    
            return $this->getContentResponse($group);
        }
    }