Provides a resource for database watchdog log entries.
@Plugin(
id = "dblog",
label = @Translation("Watchdog database log")
)
Expanded class hierarchy of DBLogResource
class DBLogResource extends ResourceBase {
/**
* Overrides \Drupal\rest\Plugin\ResourceBase::routes().
*/
public function routes() {
// Only expose routes if the dblog module is enabled.
if (module_exists('dblog')) {
return parent::routes();
}
return new RouteCollection();
}
/**
* Responds to GET requests.
*
* Returns a watchdog log entry for the specified ID.
*
* @return \Drupal\rest\ResourceResponse
* The response containing the log entry.
*
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
*/
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,
)));
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DBLogResource:: |
public | function | Responds to GET requests. | |
DBLogResource:: |
public | function |
Overrides \Drupal\rest\Plugin\ResourceBase::routes(). Overrides ResourceBase:: |
|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
public | function |
Returns the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function |
Returns the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Constructs a Drupal\Component\Plugin\PluginBase object. | 17 |
ResourceBase:: |
public | function |
Implements ResourceInterface::availableMethods(). Overrides ResourceInterface:: |
|
ResourceBase:: |
public | function |
Implements ResourceInterface::permissions(). Overrides ResourceInterface:: |
|
ResourceBase:: |
protected | function | Provides predefined HTTP request methods. |