Bristol SU Support Package
CheckAdminActivityFor.php
Go to the documentation of this file.
1 <?php
2 
4 
8 use Closure;
10 
15 {
21  private $authentication;
22 
29  {
30  $this->authentication = $authentication;
31  }
32 
40  public function handle(Request $request, Closure $next)
41  {
42  $activity = $request->route('activity_slug');
43  if (!LogicTester::evaluate($activity->adminLogic, $this->authentication->getUser(), $this->authentication->getGroup(), $this->authentication->getRole())) {
44  throw ActivityRequiresAdmin::createWithActivity($activity, 'You must be an administrator to access this page', 403);
45  }
46  return $next($request);
47  }
48 }
static createWithActivity(Activity $activity, string $message='', int $code=0)