Skip to content
Snippets Groups Projects

Issue #3145710: Drupal 9 Readiness

8 files
+ 134
37
Compare changes
  • Side-by-side
  • Inline
Files
8
@@ -5,6 +5,7 @@ namespace Drupal\download_count\Controller;
@@ -5,6 +5,7 @@ namespace Drupal\download_count\Controller;
use Drupal\Component\Utility\Unicode;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Controller\ControllerBase;
 
use Drupal\Core\Database\Connection;
use Drupal\Core\Database\Database;
use Drupal\Core\Database\Database;
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\Html;
use Drupal\Core\Datetime\DateFormatterInterface;
use Drupal\Core\Datetime\DateFormatterInterface;
@@ -59,12 +60,15 @@ class DownloadCountController extends ControllerBase implements ContainerInjecti
@@ -59,12 +60,15 @@ class DownloadCountController extends ControllerBase implements ContainerInjecti
* Date Formatter.
* Date Formatter.
* @param \Drupal\Core\Queue\QueueFactory $queue
* @param \Drupal\Core\Queue\QueueFactory $queue
* Queue Manager.
* Queue Manager.
 
* @param \Drupal\Core\Database\Connection $connection
 
* The database connection.
*/
*/
public function __construct(ConfigFactoryInterface $config_factory, AccountInterface $current_user, DateFormatterInterface $date_formatter, QueueFactory $queue) {
public function __construct(ConfigFactoryInterface $config_factory, AccountInterface $current_user, DateFormatterInterface $date_formatter, QueueFactory $queue, Connection $connection) {
$this->configFactory = $config_factory;
$this->configFactory = $config_factory;
$this->currentUser = $current_user;
$this->currentUser = $current_user;
$this->dateFormatter = $date_formatter;
$this->dateFormatter = $date_formatter;
$this->queue = $queue->get('download_count');
$this->queue = $queue->get('download_count');
 
$this->connection = $connection;
}
}
/**
/**
@@ -75,7 +79,8 @@ class DownloadCountController extends ControllerBase implements ContainerInjecti
@@ -75,7 +79,8 @@ class DownloadCountController extends ControllerBase implements ContainerInjecti
$container->get('config.factory'),
$container->get('config.factory'),
$container->get('current_user'),
$container->get('current_user'),
$container->get('date.formatter'),
$container->get('date.formatter'),
$container->get('queue')
$container->get('queue'),
 
$container->get('database')
);
);
}
}
@@ -136,8 +141,7 @@ class DownloadCountController extends ControllerBase implements ContainerInjecti
@@ -136,8 +141,7 @@ class DownloadCountController extends ControllerBase implements ContainerInjecti
'field' => 'last',
'field' => 'last',
],
],
];
];
$connection = Database::getConnection();
$query = $this->connection->select('download_count', 'dc')
$query = $connection->select('download_count', 'dc')
->fields('dc', ['type', 'id'])
->fields('dc', ['type', 'id'])
->fields('f', ['filename', 'fid', 'filesize'])
->fields('f', ['filename', 'fid', 'filesize'])
->groupBy('dc.type')
->groupBy('dc.type')
@@ -272,8 +276,7 @@ class DownloadCountController extends ControllerBase implements ContainerInjecti
@@ -272,8 +276,7 @@ class DownloadCountController extends ControllerBase implements ContainerInjecti
$last_cron = $config->get('download_count_last_cron');
$last_cron = $config->get('download_count_last_cron');
if ($download_count_entry != NULL) {
if ($download_count_entry != NULL) {
$connection = Database::getConnection();
$query = $this->connection->select('download_count', 'dc');
$query = $connection->select('download_count', 'dc');
$query->innerjoin('file_managed', 'f', 'dc.fid = f.fid');
$query->innerjoin('file_managed', 'f', 'dc.fid = f.fid');
$query->fields('dc', [
$query->fields('dc', [
'dcid',
'dcid',
@@ -295,8 +298,7 @@ class DownloadCountController extends ControllerBase implements ContainerInjecti
@@ -295,8 +298,7 @@ class DownloadCountController extends ControllerBase implements ContainerInjecti
$output = Link::fromTextAndUrl($this->t('« Back to summary'), Url::fromRoute('download_count.reports'))
$output = Link::fromTextAndUrl($this->t('« Back to summary'), Url::fromRoute('download_count.reports'))
->toString();
->toString();
$connection = Database::getConnection();
$query = $this->connection->select('download_count_cache', 'dc');
$query = $connection->select('download_count_cache', 'dc');
$query->addExpression('COUNT(dc.count)', 'count');
$query->addExpression('COUNT(dc.count)', 'count');
if (!is_object($dc_entry)) {
if (!is_object($dc_entry)) {
@@ -443,7 +445,7 @@ class DownloadCountController extends ControllerBase implements ContainerInjecti
@@ -443,7 +445,7 @@ class DownloadCountController extends ControllerBase implements ContainerInjecti
'#header' => $header,
'#header' => $header,
'#rows' => $rows,
'#rows' => $rows,
'#attributes' => [
'#attributes' => [
'id' => 'download-count-' . Unicode::strtolower($caption),
'id' => 'download-count-' . mb_strtolower($caption),
'class' => 'download-count-details download-count-table',
'class' => 'download-count-details download-count-table',
],
],
'#caption' => $caption,
'#caption' => $caption,
Loading