commit 50c9c65d4895c2c3238a1366b760b707bddfddfb Author: Christian Biggins Date: Sun Apr 28 16:12:03 2013 +1000 Removing patch diff --git a/Drupal8-Convert-dblog_overview-to-a-controller-1977254-2.patch b/Drupal8-Convert-dblog_overview-to-a-controller-1977254-2.patch deleted file mode 100644 index 3577054..0000000 --- a/Drupal8-Convert-dblog_overview-to-a-controller-1977254-2.patch +++ /dev/null @@ -1,230 +0,0 @@ -diff --git a/core/modules/dblog/dblog.module b/core/modules/dblog/dblog.module -index d28f3b7..73b9031 100644 ---- a/core/modules/dblog/dblog.module -+++ b/core/modules/dblog/dblog.module -@@ -42,8 +42,7 @@ function dblog_menu() { - $items['admin/reports/dblog'] = array( - 'title' => 'Recent log messages', - 'description' => 'View events that have recently been logged.', -- 'page callback' => 'dblog_overview', -- 'access arguments' => array('access site reports'), -+ 'route_name' => 'dblog_overview', - 'weight' => -1, - 'file' => 'dblog.admin.inc', - ); -diff --git a/core/modules/dblog/dblog.routing.yml b/core/modules/dblog/dblog.routing.yml -new file mode 100644 -index 0000000..88ef0bb ---- /dev/null -+++ b/core/modules/dblog/dblog.routing.yml -@@ -0,0 +1,6 @@ -+dblog_overview: -+ pattern: '/admin/reports/dblog' -+ defaults: -+ _content: '\Drupal\dblog\Controller\DBLogController::overview' -+ requirements: -+ _permission: 'access site reports' -\ No newline at end of file -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 100644 -index 0000000..643f655 ---- /dev/null -+++ b/core/modules/dblog/lib/Drupal/dblog/Controller/DBLogController.php -@@ -0,0 +1,197 @@ -+get('database'), -+ $container->get('module_handler') -+ ); -+ } -+ -+ /** -+ * Constructs a DBLogController object. -+ * -+ * TODO: object type? -+ */ -+ public function __construct($database, $moduleHandler) { -+ $this->database = $database; -+ $this->moduleHandler = $moduleHandler; -+ } -+ -+ /** -+ * Page callback: Displays a listing of database log messages. -+ * -+ * Messages are truncated at 56 chars. -+ * Full-length messages can be viewed on the message details page. -+ * -+ * @see dblog_clear_log_form() -+ * @see dblog_event() -+ * @see dblog_filter_form() -+ * @see dblog_menu() -+ */ -+ public function overview() { -+ -+ $filter = $this->buildFilterQuery(); -+ $rows = array(); -+ -+ $classes = array( -+ WATCHDOG_DEBUG => 'dblog-debug', -+ WATCHDOG_INFO => 'dblog-info', -+ WATCHDOG_NOTICE => 'dblog-notice', -+ WATCHDOG_WARNING => 'dblog-warning', -+ WATCHDOG_ERROR => 'dblog-error', -+ WATCHDOG_CRITICAL => 'dblog-critical', -+ WATCHDOG_ALERT => 'dblog-alert', -+ WATCHDOG_EMERGENCY => 'dblog-emergency', -+ ); -+ -+ $this->moduleHandler->loadInclude('dblog', 'admin.inc'); -+ -+ $build['dblog_filter_form'] = drupal_get_form('dblog_filter_form'); -+ $build['dblog_clear_log_form'] = drupal_get_form('dblog_clear_log_form'); -+ -+ $header = array( -+ // Icon column. -+ '', -+ array( -+ 'data' => t('Type'), -+ 'field' => 'w.type', -+ 'class' => array(RESPONSIVE_PRIORITY_MEDIUM)), -+ array( -+ 'data' => t('Date'), -+ 'field' => 'w.wid', -+ 'sort' => 'desc', -+ 'class' => array(RESPONSIVE_PRIORITY_LOW)), -+ t('Message'), -+ array( -+ 'data' => t('User'), -+ 'field' => 'u.name', -+ 'class' => array(RESPONSIVE_PRIORITY_MEDIUM)), -+ array( -+ 'data' => t('Operations'), -+ 'class' => array(RESPONSIVE_PRIORITY_LOW)), -+ ); -+ -+ $query = $this->database->select('watchdog', 'w') -+ ->extend('Drupal\Core\Database\Query\PagerSelectExtender') -+ ->extend('Drupal\Core\Database\Query\TableSortExtender'); -+ $query->leftJoin('users', 'u', 'w.uid = u.uid'); -+ $query->fields('w', array('wid', 'uid', 'severity', 'type', -+ 'timestamp', 'message', 'variables', 'link')) -+ ->addField('u', 'name'); -+ -+ if (!empty($filter['where'])) { -+ $query->where($filter['where'], $filter['args']); -+ } -+ $result = $query -+ ->limit(50) -+ ->orderByHeader($header) -+ ->execute(); -+ -+ foreach ($result as $dblog) { -+ // 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)); -+ } -+ if (isset($dblog->wid)) { -+ // Truncate link_text to 56 chars of message. -+ $log_text = truncate_utf8(filter_xss($message, array()), 56, TRUE, TRUE); -+ $message = l($log_text, 'admin/reports/event/' . $dblog->wid, array('html' => TRUE)); -+ } -+ } -+ $rows[] = array( -+ 'data' => array( -+ // Cells. -+ array('class' => array('icon')), -+ t($dblog->type), -+ format_date($dblog->timestamp, 'short'), -+ $message, -+ theme('username', array('account' => $dblog)), -+ filter_xss($dblog->link), -+ ), -+ // Attributes for table row. -+ 'class' => array(drupal_html_class('dblog-' . $dblog->type), $classes[$dblog->severity]), -+ ); -+ } -+ -+ $build['dblog_table'] = array( -+ '#theme' => 'table', -+ '#header' => $header, -+ '#rows' => $rows, -+ '#attributes' => array('id' => 'admin-dblog', 'class' => array('admin-dblog')), -+ '#empty' => t('No log messages available.'), -+ ); -+ $build['dblog_pager'] = array('#theme' => 'pager'); -+ -+ return $build; -+ -+ } -+ -+ /** -+ * Builds a query for database log administration filters based on session. -+ * -+ * @return array -+ * An associative array with keys 'where' and 'args'. -+ */ -+ protected function buildFilterQuery() { -+ if (empty($_SESSION['dblog_overview_filter'])) { -+ return; -+ } -+ -+ $this->moduleHandler->loadInclude('dblog', 'admin.inc'); -+ -+ $filters = dblog_filters(); -+ -+ // Build query. -+ $where = $args = array(); -+ foreach ($_SESSION['dblog_overview_filter'] as $key => $filter) { -+ $filter_where = array(); -+ foreach ($filter as $value) { -+ $filter_where[] = $filters[$key]['where']; -+ $args[] = $value; -+ } -+ if (!empty($filter_where)) { -+ $where[] = '(' . implode(' OR ', $filter_where) . ')'; -+ } -+ } -+ $where = !empty($where) ? implode(' AND ', $where) : ''; -+ -+ return array( -+ 'where' => $where, -+ 'args' => $args, -+ ); -+ } -+} commit 63eb863edd066f24f69c761f72377fbee3909067 Author: Christian Biggins Date: Sun Apr 28 16:16:46 2013 +1000 Updating controller based on issue feedback diff --git a/core/modules/dblog/lib/Drupal/dblog/Controller/DBLogController.php b/core/modules/dblog/lib/Drupal/dblog/Controller/DBLogController.php index 096ca42..00461dd 100644 --- a/core/modules/dblog/lib/Drupal/dblog/Controller/DBLogController.php +++ b/core/modules/dblog/lib/Drupal/dblog/Controller/DBLogController.php @@ -6,6 +6,7 @@ namespace Drupal\dblog\Controller; +use Drupal\Core\Database\Connection; use Drupal\Core\ControllerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -38,7 +39,7 @@ public static function create(ContainerInterface $container) { /** * Constructs a DBLogController object. */ - public function __construct(Connection $database, ModuleHandler $module_handler) { + public function __construct(Connection $database, ModuleHandlerInterface $module_handler) { $this->database = $database; $this->moduleHandler = $module_handler; } @@ -100,9 +101,17 @@ public function overview() { ->extend('Drupal\Core\Database\Query\PagerSelectExtender') ->extend('Drupal\Core\Database\Query\TableSortExtender'); $query->leftJoin('users', 'u', 'w.uid = u.uid'); - $query->fields('w', array('wid', 'uid', 'severity', 'type', - 'timestamp', 'message', 'variables', 'link')) - ->addField('u', 'name'); + $query->fields('w', array( + 'wid', + 'uid', + 'severity', + 'type', + 'timestamp', + 'message', + 'variables', + 'link', + )); + $query->addField('u', 'name'); if (!empty($filter['where'])) { $query->where($filter['where'], $filter['args']); @@ -191,4 +200,5 @@ protected function buildFilterQuery() { 'args' => $args, ); } + }