diff --git a/core/modules/dblog/dblog.admin.inc b/core/modules/dblog/dblog.admin.inc index d432b5b..aa493d1 100644 --- a/core/modules/dblog/dblog.admin.inc +++ b/core/modules/dblog/dblog.admin.inc @@ -166,82 +166,7 @@ function dblog_top($type) { return $build; } -/** - * Page callback: Displays details about a specific database log message. - * - * @param int $id - * Unique ID of the database log message. - * - * @return array|string - * If the ID is located in the Database Logging table, a build array in the - * format expected by drupal_render(); otherwise, an empty string. - * - * @see dblog_menu() - */ -function dblog_event($id) { - $severity = watchdog_severity_levels(); - $result = db_query('SELECT w.*, u.name, u.uid FROM {watchdog} w INNER JOIN {users} u ON w.uid = u.uid WHERE w.wid = :id', array(':id' => $id))->fetchObject(); - if ($dblog = $result) { - // Check for required properties. - if (isset($dblog->message) && isset($dblog->variables)) { - // Messages without variables or user specified text. - if ($dblog->variables === 'N;') { - $message = $dblog->message; - } - // Message to translate with injected variables. - else { - $message = t($dblog->message, unserialize($dblog->variables)); - } - } - $rows = array( - array( - array('data' => t('Type'), 'header' => TRUE), - t($dblog->type), - ), - array( - array('data' => t('Date'), 'header' => TRUE), - format_date($dblog->timestamp, 'long'), - ), - array( - array('data' => t('User'), 'header' => TRUE), - theme('username', array('account' => $dblog)), - ), - array( - array('data' => t('Location'), 'header' => TRUE), - l($dblog->location, $dblog->location), - ), - array( - array('data' => t('Referrer'), 'header' => TRUE), - l($dblog->referer, $dblog->referer), - ), - array( - array('data' => t('Message'), 'header' => TRUE), - $message, - ), - array( - array('data' => t('Severity'), 'header' => TRUE), - $severity[$dblog->severity], - ), - array( - array('data' => t('Hostname'), 'header' => TRUE), - check_plain($dblog->hostname), - ), - array( - array('data' => t('Operations'), 'header' => TRUE), - $dblog->link, - ), - ); - $build['dblog_table'] = array( - '#theme' => 'table', - '#rows' => $rows, - '#attributes' => array('class' => array('dblog-event')), - ); - return $build; - } - else { - return ''; - } -} + /** * Builds a query for database log administration filters based on session. diff --git a/core/modules/dblog/dblog.module b/core/modules/dblog/dblog.module index d28f3b7..cf5bb03 100644 --- a/core/modules/dblog/dblog.module +++ b/core/modules/dblog/dblog.module @@ -65,10 +65,7 @@ function dblog_menu() { ); $items['admin/reports/event/%'] = array( 'title' => 'Details', - 'page callback' => 'dblog_event', - 'page arguments' => array(3), - 'access arguments' => array('access site reports'), - 'file' => 'dblog.admin.inc', + 'route_name' => 'dblog_event', ); if (module_exists('search')) { diff --git a/core/modules/dblog/dblog.routing.yml b/core/modules/dblog/dblog.routing.yml new file mode 100644 index 0000000..5479ade --- /dev/null +++ b/core/modules/dblog/dblog.routing.yml @@ -0,0 +1,6 @@ +dblog_event: + pattern: 'admin/reports/event/{eventId}' + defaults: + _content: '\Drupal\dblog\Controller\DBLogController::eventDetails' + requirements: + _permission: 'access site reports' diff --git a/core/modules/dblog/lib/Drupal/dblog/Controller/DbLogController.php b/core/modules/dblog/lib/Drupal/dblog/Controller/DbLogController.php new file mode 100755 index 0000000..4d12bc3 --- /dev/null +++ b/core/modules/dblog/lib/Drupal/dblog/Controller/DbLogController.php @@ -0,0 +1,111 @@ +database = $database; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + return new static($container->get('database')); + } + + /** + * Displays details about a specific database log message. + * + * @param int $eventId + * Unique ID of the database log message. + * + * @return array + * If the ID is located in the Database Logging table, a build array in the + * format expected by drupal_render(); + * + * @see dblog_menu() + */ + function eventDetails($eventId) { + $build = array(); + if ($dblog = $this->database->query('SELECT w.*, u.name, u.uid FROM {watchdog} w INNER JOIN {users} u ON w.uid = u.uid WHERE w.wid = :id', array(':id' => $eventId))->fetchObject()) { + $severity = watchdog_severity_levels(); + // Check for required properties. + if (isset($dblog->message) && isset($dblog->variables)) { + // Inject variables into the message if required. + $message = $dblog->variables === 'N;' ? $dblog->message : t($dblog->message, unserialize($dblog->variables)); + } + $rows = array( + array( + array('data' => t('Type'), 'header' => TRUE), + t($dblog->type), + ), + array( + array('data' => t('Date'), 'header' => TRUE), + format_date($dblog->timestamp, 'long'), + ), + array( + array('data' => t('User'), 'header' => TRUE), + theme('username', array('account' => $dblog)), + ), + array( + array('data' => t('Location'), 'header' => TRUE), + l($dblog->location, $dblog->location), + ), + array( + array('data' => t('Referrer'), 'header' => TRUE), + l($dblog->referer, $dblog->referer), + ), + array( + array('data' => t('Message'), 'header' => TRUE), + $message, + ), + array( + array('data' => t('Severity'), 'header' => TRUE), + $severity[$dblog->severity], + ), + array( + array('data' => t('Hostname'), 'header' => TRUE), + check_plain($dblog->hostname), + ), + array( + array('data' => t('Operations'), 'header' => TRUE), + $dblog->link, + ), + ); + $build['dblog_table'] = array( + '#theme' => 'table', + '#rows' => $rows, + '#attributes' => array('class' => array('dblog-event')), + ); + } + + return $build; + } + +}