Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / statistics / statistics.php
1 <?php
2
3 /**
4  * @file
5  * Handles counts of node views via AJAX with minimal bootstrap.
6  */
7
8 use Drupal\Core\DrupalKernel;
9 use Symfony\Component\HttpFoundation\Request;
10
11 chdir('../../..');
12
13 $autoloader = require_once 'autoload.php';
14
15 $kernel = DrupalKernel::createFromRequest(Request::createFromGlobals(), $autoloader, 'prod');
16 $kernel->boot();
17 $container = $kernel->getContainer();
18
19 $views = $container
20   ->get('config.factory')
21   ->get('statistics.settings')
22   ->get('count_content_views');
23
24 if ($views) {
25   $nid = filter_input(INPUT_POST, 'nid', FILTER_VALIDATE_INT);
26   if ($nid) {
27     $container->get('request_stack')->push(Request::createFromGlobals());
28     $container->get('statistics.storage.node')->recordView($nid);
29   }
30 }