public function DBLogResource::get

Responds to GET requests.

Returns a watchdog log entry for the specified ID.

Return value

\Drupal\rest\ResourceResponse The response containing the log entry.

Throws

\Symfony\Component\HttpKernel\Exception\HttpException

File

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

Class

DBLogResource
Provides a resource for database watchdog log entries.

Namespace

Drupal\rest\Plugin\rest\resource

Code

public function get($id = NULL) {
  if ($id) {
    $record = db_query("SELECT * FROM {watchdog} WHERE wid = :wid", array(
      ':wid' => $id,
    ))
      ->fetchAssoc();
    if (!empty($record)) {
      return new ResourceResponse($record);
    }
  }
  throw new NotFoundHttpException(t('Log entry with ID @id was not found', array(
    '@id' => $id,
  )));
}