You are here

public function ResourceController::test in OAuth2 Server 8

Same name and namespace in other branches
  1. 2.0.x tests/modules/oauth2_server_test/src/Controller/ResourceController.php \Drupal\oauth2_server_test\Controller\ResourceController::test()

Test resource.

Parameters

\Drupal\Core\Routing\RouteMatchInterface $route_match: The route match interface.

\Symfony\Component\HttpFoundation\Request $request: The request object.

Return value

array|\OAuth2\Response|\Symfony\Component\HttpFoundation\JsonResponse The json response.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

1 string reference to 'ResourceController::test'
oauth2_server_test.routing.yml in tests/modules/oauth2_server_test/oauth2_server_test.routing.yml
tests/modules/oauth2_server_test/oauth2_server_test.routing.yml

File

tests/modules/oauth2_server_test/src/Controller/ResourceController.php, line 31

Class

ResourceController
Provides block routines for OAuth2 server test.

Namespace

Drupal\oauth2_server_test\Controller

Code

public function test(RouteMatchInterface $route_match, Request $request) {
  $scope = $route_match
    ->getRawParameter('oauth2_server_scope');
  $response = Utility::checkAccess('test_server', $scope);
  if ($response instanceof ResponseInterface) {
    return $response;
  }
  elseif (is_array($response)) {
    return new JsonResponse($response);
  }
  return new JsonResponse([
    'error' => 'No response',
  ]);
}