Move into nested docroot

This commit is contained in:
Rob Davies 2017-02-13 15:31:17 +00:00
parent 83a0d3a149
commit c8b70abde9
13405 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,53 @@
<?php
namespace Drupal\dblog\Plugin\rest\resource;
use Drupal\rest\Plugin\ResourceBase;
use Drupal\rest\ResourceResponse;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* Provides a resource for database watchdog log entries.
*
* @RestResource(
* id = "dblog",
* label = @Translation("Watchdog database log"),
* uri_paths = {
* "canonical" = "/dblog/{id}"
* }
* )
*/
class DBLogResource extends ResourceBase {
/**
* Responds to GET requests.
*
* Returns a watchdog log entry for the specified ID.
*
* @param int $id
* The ID of the watchdog log entry.
*
* @return \Drupal\rest\ResourceResponse
* The response containing the log entry.
*
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
* Thrown when the log entry was not found.
* @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
* Thrown when no log entry was provided.
*/
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)));
}
throw new BadRequestHttpException(t('No log entry ID was provided'));
}
}

View file

@ -0,0 +1,70 @@
<?php
namespace Drupal\dblog\Plugin\views\field;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Form\FormStateInterface;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\ResultRow;
use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
/**
* Provides a field handler that renders a log event with replaced variables.
*
* @ingroup views_field_handlers
*
* @ViewsField("dblog_message")
*/
class DblogMessage extends FieldPluginBase {
/**
* {@inheritdoc}
*/
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $display, $options);
if ($this->options['replace_variables']) {
$this->additional_fields['variables'] = 'variables';
}
}
/**
* {@inheritdoc}
*/
protected function defineOptions() {
$options = parent::defineOptions();
$options['replace_variables'] = array('default' => TRUE);
return $options;
}
/**
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$form['replace_variables'] = array(
'#title' => $this->t('Replace variables'),
'#type' => 'checkbox',
'#default_value' => $this->options['replace_variables'],
);
}
/**
* {@inheritdoc}
*/
public function render(ResultRow $values) {
$value = $this->getValue($values);
if ($this->options['replace_variables']) {
$variables = unserialize($this->getvalue($values, 'variables'));
return SafeMarkup::format($value, (array) $variables);
}
else {
return $this->sanitizeValue($value);
}
}
}

View file

@ -0,0 +1,32 @@
<?php
namespace Drupal\dblog\Plugin\views\field;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\ResultRow;
/**
* Provides a field handler that renders operation link markup.
*
* @ingroup views_field_handlers
*
* @ViewsField("dblog_operations")
*/
class DblogOperations extends FieldPluginBase {
/**
* {@inheritdoc}
*/
public function clickSortable() {
return FALSE;
}
/**
* {@inheritdoc}
*/
public function render(ResultRow $values) {
$value = $this->getValue($values);
return $this->sanitizeValue($value, 'xss_admin');
}
}

View file

@ -0,0 +1,37 @@
<?php
namespace Drupal\dblog\Plugin\views\wizard;
use Drupal\views\Plugin\views\wizard\WizardPluginBase;
/**
* Defines a wizard for the watchdog table.
*
* @ViewsWizard(
* id = "watchdog",
* module = "dblog",
* base_table = "watchdog",
* title = @Translation("Log entries")
* )
*/
class Watchdog extends WizardPluginBase {
/**
* Set the created column.
*/
protected $createdColumn = 'timestamp';
/**
* {@inheritdoc}
*/
protected function defaultDisplayOptions() {
$display_options = parent::defaultDisplayOptions();
// Add permission-based access control.
$display_options['access']['type'] = 'perm';
$display_options['access']['options']['perm'] = 'access site reports';
return $display_options;
}
}