You are here

public function AliasGet::processRequest in Services 9.0.x

Same name and namespace in other branches
  1. 8.4 src/Plugin/ServiceDefinition/AliasGet.php \Drupal\services\Plugin\ServiceDefinition\AliasGet::processRequest()

Processes the request and returns an array of data as appropriate.

Parameters

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

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

\Symfony\Component\Serializer\SerializerInterface $serializer: The serializer. Some methods might require the plugin to leverage the serializer after extracting the request contents.

Return value

array The response.

Throws

\Symfony\Component\HttpKernel\Exception\HttpException

Overrides ServiceDefinitionInterface::processRequest

File

src/Plugin/ServiceDefinition/AliasGet.php, line 57

Class

AliasGet
Plugin annotation @ServiceDefinition( id = "alias_get", methods = { "GET" }, translatable = true, deriver = "\Drupal\services\Plugin\Deriver\AliasGet" )

Namespace

Drupal\services\Plugin\ServiceDefinition

Code

public function processRequest(Request $request, RouteMatchInterface $route_match, SerializerInterface $serializer) {

  // The query string parameter 'path' must exist in order to load the
  // node that correlates to path value provided.
  if (!$request->query
    ->has('path')) {
    throw new HttpException(404);
  }
  $this
    ->buildResponseObject($request);
  return $this->entity
    ->toArray();
}