Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/statistics/statistics.php @ 0:c75dbcec494b
Initial commit from drush-created site
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2018 14:24:15 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c75dbcec494b |
---|---|
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 } |