5 * Install and update functions for the Statistics module.
9 * Implements hook_uninstall().
11 function statistics_uninstall() {
13 \Drupal::state()->delete('statistics.node_counter_scale');
14 \Drupal::state()->delete('statistics.day_timestamp');
18 * Implements hook_schema().
20 function statistics_schema() {
21 $schema['node_counter'] = [
22 'description' => 'Access statistics for {node}s.',
25 'description' => 'The {node}.nid for these statistics.',
32 'description' => 'The total number of times the {node} has been viewed.',
40 'description' => 'The total number of times the {node} has been viewed today.',
48 'description' => 'The most recent time the {node} has been viewed.',
55 'primary key' => ['nid'],
62 * Disable the Statistics module if the node module is not enabled.
64 function statistics_update_8001() {
65 if (!\Drupal::moduleHandler()->moduleExists('node')) {
66 if (\Drupal::service('module_installer')->uninstall(['statistics'], TRUE)) {
67 return 'The statistics module depends on the node module and has therefore been uninstalled.';
70 return 'There was an error uninstalling the statistcs module.';
76 * Disable the Statistics module if the node module is not enabled.
78 function statistics_update_8002() {
79 // Set the new configuration setting for max age to the initial value.
80 \Drupal::configFactory()->getEditable('statistics.settings')->set('display_max_age', 3600)->save();
84 * Remove access_log settings.
86 function statistics_update_8300() {
87 \Drupal::configFactory()->getEditable('statistics.settings')->clear('access_log')->save();