Mercurial > hg > cmmr2012-drupal-site
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/modules/statistics/statistics.php Thu Jul 05 14:24:15 2018 +0000 @@ -0,0 +1,30 @@ +<?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(); +$container = $kernel->getContainer(); + +$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) { + $container->get('request_stack')->push(Request::createFromGlobals()); + $container->get('statistics.storage.node')->recordView($nid); + } +}