public function EntityResource::get

Responds to entity GET requests.

Parameters

mixed $id: The entity ID.

Return value

\Drupal\rest\ResourceResponse The response containing the loaded entity.

Throws

\Symfony\Component\HttpKernel\Exception\HttpException

File

drupal/core/modules/rest/lib/Drupal/rest/Plugin/rest/resource/EntityResource.php, line 40
Definition of Drupal\rest\Plugin\rest\resource\EntityResource.

Class

EntityResource
Represents entities as resources.

Namespace

Drupal\rest\Plugin\rest\resource

Code

public function get($id) {
  $definition = $this
    ->getDefinition();
  $entity = entity_load($definition['entity_type'], $id);
  if ($entity) {
    return new ResourceResponse($entity);
  }
  throw new NotFoundHttpException(t('Entity with ID @id not found', array(
    '@id' => $id,
  )));
}