You are here

protected function RestfulEntityAndPropertyAccessTestCase::doRequest in RESTful 7.2

Helper method to format a request.

Parameters

string $method: The HTTP verb.

\Drupal\restful\Plugin\resource\ResourceInterface $handler: The handler.

array $input: The parsed body array.

string $path: The path where to make the request.

Return value

array The formatted output.

4 calls to RestfulEntityAndPropertyAccessTestCase::doRequest()
RestfulEntityAndPropertyAccessTestCase::testCreateAccess in tests/RestfulEntityAndPropertyAccessTestCase.test
Test access control for creating an entity.
RestfulEntityAndPropertyAccessTestCase::testPublicFieldAccess in tests/RestfulEntityAndPropertyAccessTestCase.test
Test access callback per public field.
RestfulEntityAndPropertyAccessTestCase::testUpdateAccess in tests/RestfulEntityAndPropertyAccessTestCase.test
Test access control for updating an entity.
RestfulEntityAndPropertyAccessTestCase::testViewAccess in tests/RestfulEntityAndPropertyAccessTestCase.test
Test access control for viewing an entity.

File

tests/RestfulEntityAndPropertyAccessTestCase.test, line 240
Contains RestfulEntityAndPropertyAccessTestCase

Class

RestfulEntityAndPropertyAccessTestCase

Code

protected function doRequest($method, \Drupal\restful\Plugin\resource\ResourceInterface $handler, array $input = array(), $path = '') {
  $output = NULL;
  if ($method == \Drupal\restful\Http\RequestInterface::METHOD_POST) {
    $output = $handler
      ->doPost($input);
  }
  elseif ($method == \Drupal\restful\Http\RequestInterface::METHOD_PUT) {
    $output = $handler
      ->doPut($path, $input);
  }
  elseif ($method == \Drupal\restful\Http\RequestInterface::METHOD_PATCH) {
    $output = $handler
      ->doPatch($path, $input);
  }
  elseif ($method == \Drupal\restful\Http\RequestInterface::METHOD_GET) {
    $output = $handler
      ->doGet($path, $input);
  }
  if (!isset($output)) {
    return NULL;
  }
  $formatter = restful()
    ->getFormatterManager()
    ->negotiateFormatter(NULL, 'json');
  $formatter
    ->setResource($handler);
  return $formatter
    ->prepare($output);
}