Pull merge.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d8 / install.twig
1 <?php
2
3 /**
4  * @file
5  * Install, update and uninstall functions for the {{ name }} module.
6  */
7
8 /**
9  * Implements hook_install().
10  */
11 function {{ machine_name }}_install() {
12   \Drupal::messenger()->addStatus(__FUNCTION__);
13 }
14
15 /**
16  * Implements hook_uninstall().
17  */
18 function {{ machine_name }}_uninstall() {
19   \Drupal::messenger()->addStatus(__FUNCTION__);
20 }
21
22 /**
23  * Implements hook_schema().
24  */
25 function {{ machine_name }}_schema() {
26   $schema['{{ machine_name }}_example'] = [
27     'description' => 'Table description.',
28     'fields' => [
29       'id' => [
30         'type' => 'serial',
31         'not null' => TRUE,
32         'description' => 'Primary Key: Unique record ID.',
33       ],
34       'uid' => [
35         'type' => 'int',
36         'unsigned' => TRUE,
37         'not null' => TRUE,
38         'default' => 0,
39         'description' => 'The {users}.uid of the user who created the record.',
40       ],
41       'status' => [
42         'description' => 'Boolean indicating whether this record is active.',
43         'type' => 'int',
44         'unsigned' => TRUE,
45         'not null' => TRUE,
46         'default' => 0,
47         'size' => 'tiny',
48       ],
49       'type' => [
50         'type' => 'varchar_ascii',
51         'length' => 64,
52         'not null' => TRUE,
53         'default' => '',
54         'description' => 'Type of the record.',
55       ],
56       'created' => [
57         'type' => 'int',
58         'not null' => TRUE,
59         'default' => 0,
60         'description' => 'Timestamp when the record was created.',
61       ],
62       'data' => [
63         'type' => 'blob',
64         'not null' => TRUE,
65         'size' => 'big',
66         'description' => 'The arbitrary data for the item.',
67       ],
68     ],
69     'primary key' => ['id'],
70     'indexes' => [
71       'type' => ['type'],
72       'uid' => ['uid'],
73       'status' => ['status'],
74     ],
75   ];
76
77   return $schema;
78 }
79
80 /**
81  * Implements hook_requirements().
82  */
83 function {{ machine_name }}_requirements($phase) {
84   $requirements = [];
85
86   if ($phase == 'runtime') {
87     $value = mt_rand(0, 100);
88     $requirements['{{ machine_name }}_status'] = [
89       'title' => t('{{ name }} status'),
90       'value' => t('{{ name }} value: @value', ['@value' => $value]),
91       'severity' => $value > 50 ? REQUIREMENT_INFO : REQUIREMENT_WARNING,
92     ];
93   }
94
95   return $requirements;
96 }