Drupal 8.0.0 beta 12. More info: https://www.drupal.org/node/2514176
This commit is contained in:
commit
9921556621
13277 changed files with 1459781 additions and 0 deletions
38
core/modules/statistics/statistics.php
Normal file
38
core/modules/statistics/statistics.php
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?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();
|
||||
|
||||
$views = $kernel->getContainer()
|
||||
->get('config.factory')
|
||||
->get('statistics.settings')
|
||||
->get('count_content_views');
|
||||
|
||||
if ($views) {
|
||||
$nid = filter_input(INPUT_POST, 'nid', FILTER_VALIDATE_INT);
|
||||
if ($nid) {
|
||||
\Drupal::database()->merge('node_counter')
|
||||
->key('nid', $nid)
|
||||
->fields(array(
|
||||
'daycount' => 1,
|
||||
'totalcount' => 1,
|
||||
'timestamp' => REQUEST_TIME,
|
||||
))
|
||||
->expression('daycount', 'daycount + 1')
|
||||
->expression('totalcount', 'totalcount + 1')
|
||||
->execute();
|
||||
}
|
||||
}
|
||||
|
Reference in a new issue