Skip to content
Snippets Groups Projects
Commit 89c4d691 authored by Gisle Hannemyr's avatar Gisle Hannemyr Committed by Gisle Hannemyr
Browse files

Issue #3350929 by gisle: Fixed Drupal 10 compatibility

parent 386e4eff
No related branches found
No related tags found
No related merge requests found
......@@ -2,16 +2,18 @@
namespace Drupal\statistics_counter\EventSubscriber;
use Drupal;
use Drupal\Core\Database\Database;
use Drupal\Core\Render\HtmlResponse;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\TerminateEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Drupal\Core\Database\Database;
/**
* Subscribe to KernelEvents::TERMINATE events to recalculate nodes statistics.
*/
class StatisticsCounterSubscriber implements EventSubscriberInterface {
/**
* {@inheritdoc}
*/
......@@ -23,16 +25,17 @@ class StatisticsCounterSubscriber implements EventSubscriberInterface {
/**
* Update statistics.
*
* @param Symfony\Component\EventDispatcher\Event $event
* @param \Symfony\Component\HttpKernel\Event\TerminateEvent $event
* Event.
*/
static function updateStatistics(Event $event) {
$node = \Drupal::request()->attributes->get('node');
$views = \Drupal::config('statistics.settings')->get('count_content_views');
static function updateStatistics(TerminateEvent $event) {
$node = Drupal::request()->attributes->get('node');
$views = Drupal::config('statistics.settings')->get('count_content_views');
if ($node && ($event->getResponse() instanceof HtmlResponse) && $views) {
// Support statistics filter.
if (\Drupal::moduleHandler()->moduleExists('statistics_filter') && statistics_filter_do_filter()) {
if (Drupal::moduleHandler()
->moduleExists('statistics_filter') && statistics_filter_do_filter()) {
return;
}
......
......@@ -2,6 +2,6 @@ name: 'Statistics Counter'
type: module
description: 'Logs access statistics in week, month and year for your site.'
package: 'Statistics'
core_version_requirement: ^8.8 || ^9
core_version_requirement: ^8.8 || ^9 || ^10
dependencies:
- drupal:statistics
......@@ -46,7 +46,7 @@ function statistics_counter_cron() {
->execute();
}
\Drupal::state()->set('statistics_counter.timestamp', REQUEST_TIME);
\Drupal::state()->set('statistics_counter.timestamp', \Drupal::time()->getRequestTime());
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment