This repository has been archived on 2025-01-19. You can view files and clone it, but cannot push or open issues or pull requests.
drupalcampbristol/web/core/modules/statistics/statistics.php

31 lines
728 B
PHP
Raw Normal View History

<?php
/**
* @file
* Handles counts of node views via AJAX with minimal bootstrap.
*/
use Drupal\Core\DrupalKernel;
use Symfony\Component\HttpFoundation\Request;
chdir('../../..');
$autoloader = require_once 'autoload.php';
$kernel = DrupalKernel::createFromRequest(Request::createFromGlobals(), $autoloader, 'prod');
$kernel->boot();
2017-04-13 14:53:35 +00:00
$container = $kernel->getContainer();
2017-04-13 14:53:35 +00:00
$views = $container
->get('config.factory')
->get('statistics.settings')
->get('count_content_views');
if ($views) {
$nid = filter_input(INPUT_POST, 'nid', FILTER_VALIDATE_INT);
if ($nid) {
2017-04-13 14:53:35 +00:00
$container->get('request_stack')->push(Request::createFromGlobals());
$container->get('statistics.storage.node')->recordView($nid);
}
}