comparison core/modules/statistics/statistics.install @ 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 * Install and update functions for the Statistics module.
6 */
7
8 /**
9 * Implements hook_uninstall().
10 */
11 function statistics_uninstall() {
12 // Remove states.
13 \Drupal::state()->delete('statistics.node_counter_scale');
14 \Drupal::state()->delete('statistics.day_timestamp');
15 }
16
17 /**
18 * Implements hook_schema().
19 */
20 function statistics_schema() {
21 $schema['node_counter'] = [
22 'description' => 'Access statistics for {node}s.',
23 'fields' => [
24 'nid' => [
25 'description' => 'The {node}.nid for these statistics.',
26 'type' => 'int',
27 'unsigned' => TRUE,
28 'not null' => TRUE,
29 'default' => 0,
30 ],
31 'totalcount' => [
32 'description' => 'The total number of times the {node} has been viewed.',
33 'type' => 'int',
34 'unsigned' => TRUE,
35 'not null' => TRUE,
36 'default' => 0,
37 'size' => 'big',
38 ],
39 'daycount' => [
40 'description' => 'The total number of times the {node} has been viewed today.',
41 'type' => 'int',
42 'unsigned' => TRUE,
43 'not null' => TRUE,
44 'default' => 0,
45 'size' => 'medium',
46 ],
47 'timestamp' => [
48 'description' => 'The most recent time the {node} has been viewed.',
49 'type' => 'int',
50 'unsigned' => TRUE,
51 'not null' => TRUE,
52 'default' => 0,
53 ],
54 ],
55 'primary key' => ['nid'],
56 ];
57
58 return $schema;
59 }
60
61 /**
62 * Disable the Statistics module if the node module is not enabled.
63 */
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.';
68 }
69 else {
70 return 'There was an error uninstalling the statistcs module.';
71 }
72 }
73 }
74
75 /**
76 * Disable the Statistics module if the node module is not enabled.
77 */
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();
81 }
82
83 /**
84 * Remove access_log settings.
85 */
86 function statistics_update_8300() {
87 \Drupal::configFactory()->getEditable('statistics.settings')->clear('access_log')->save();
88 }