MenuTreeStorage::schemaDefinition

protected static MenuTreeStorage::schemaDefinition()

Defines the schema for the tree table.

Return value

array The schema API definition for the SQL storage table.

File

core/lib/Drupal/Core/Menu/MenuTreeStorage.php, line 1204

Class

MenuTreeStorage
Provides a menu tree storage using the database.

Namespace

Drupal\Core\Menu

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
protected static function schemaDefinition() {
  $schema = array(
    'description' => 'Contains the menu tree hierarchy.',
    'fields' => array(
      'menu_name' => array(
        'description' => "The menu name. All links with the same menu name (such as 'tools') are part of the same menu.",
        'type' => 'varchar_ascii',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'mlid' => array(
        'description' => 'The menu link ID (mlid) is the integer primary key.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'id' => array(
        'description' => 'Unique machine name: the plugin ID.',
        'type' => 'varchar_ascii',
        'length' => 255,
        'not null' => TRUE,
      ),
      'parent' => array(
        'description' => 'The plugin ID for the parent of this link.',
        'type' => 'varchar_ascii',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'route_name' => array(
        'description' => 'The machine name of a defined Symfony Route this menu item represents.',
        'type' => 'varchar_ascii',
        'length' => 255,
      ),
      'route_param_key' => array(
        'description' => 'An encoded string of route parameters for loading by route.',
        'type' => 'varchar',
        'length' => 255,
      ),
      'route_parameters' => array(
        'description' => 'Serialized array of route parameters of this menu link.',
        'type' => 'blob',
        'size' => 'big',
        'not null' => FALSE,
        'serialize' => TRUE,
      ),
      'url' => array(
        'description' => 'The external path this link points to (when not using a route).',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'title' => array(
        'description' => 'The serialized title for the link. May be a TranslatableMarkup.',
        'type' => 'blob',
        'size' => 'big',
        'not null' => FALSE,
        'serialize' => TRUE,
      ),
      'description' => array(
        'description' => 'The serialized description of this link - used for admin pages and title attribute. May be a TranslatableMarkup.',
        'type' => 'blob',
        'size' => 'big',
        'not null' => FALSE,
        'serialize' => TRUE,
      ),
      'class' => array(
        'description' => 'The class for this link plugin.',
        'type' => 'text',
        'not null' => FALSE,
      ),
      'options' => array(
        'description' => 'A serialized array of URL options, such as a query string or HTML attributes.',
        'type' => 'blob',
        'size' => 'big',
        'not null' => FALSE,
        'serialize' => TRUE,
      ),
      'provider' => array(
        'description' => 'The name of the module that generated this link.',
        'type' => 'varchar_ascii',
        'length' => DRUPAL_EXTENSION_NAME_MAX_LENGTH,
        'not null' => TRUE,
        'default' => 'system',
      ),
      'enabled' => array(
        'description' => 'A flag for whether the link should be rendered in menus. (0 = a disabled menu item that may be shown on admin screens, 1 = a normal, visible link)',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 1,
        'size' => 'small',
      ),
      'discovered' => array(
        'description' => 'A flag for whether the link was discovered, so can be purged on rebuild',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'small',
      ),
      'expanded' => array(
        'description' => 'Flag for whether this link should be rendered as expanded in menus - expanded links always have their child links displayed, instead of only when the link is in the active trail (1 = expanded, 0 = not expanded)',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'small',
      ),
      'weight' => array(
        'description' => 'Link weight among links in the same menu at the same depth.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'metadata' => array(
        'description' => 'A serialized array of data that may be used by the plugin instance.',
        'type' => 'blob',
        'size' => 'big',
        'not null' => FALSE,
        'serialize' => TRUE,
      ),
      'has_children' => array(
        'description' => 'Flag indicating whether any enabled links have this link as a parent (1 = enabled children exist, 0 = no enabled children).',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'small',
      ),
      'depth' => array(
        'description' => 'The depth relative to the top level. A link with empty parent will have depth == 1.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'small',
      ),
      'p1' => array(
        'description' => 'The first mlid in the materialized path. If N = depth, then pN must equal the mlid. If depth > 1 then p(N-1) must equal the parent link mlid. All pX where X > depth must equal zero. The columns p1 .. p9 are also called the parents.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'p2' => array(
        'description' => 'The second mlid in the materialized path. See p1.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'p3' => array(
        'description' => 'The third mlid in the materialized path. See p1.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'p4' => array(
        'description' => 'The fourth mlid in the materialized path. See p1.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'p5' => array(
        'description' => 'The fifth mlid in the materialized path. See p1.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'p6' => array(
        'description' => 'The sixth mlid in the materialized path. See p1.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'p7' => array(
        'description' => 'The seventh mlid in the materialized path. See p1.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'p8' => array(
        'description' => 'The eighth mlid in the materialized path. See p1.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'p9' => array(
        'description' => 'The ninth mlid in the materialized path. See p1.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'form_class' => array(
        'description' => 'meh',
        'type' => 'varchar',
        'length' => 255,
      ),
    ),
    'indexes' => array(
      'menu_parents' => array(
        'menu_name',
        'p1',
        'p2',
        'p3',
        'p4',
        'p5',
        'p6',
        'p7',
        'p8',
        'p9',
      ),
      // @todo Test this index for effectiveness.
      'menu_parent_expand_child' => array(
        'menu_name', 'expanded',
        'has_children',
        array('parent', 16),
      ),
      'route_values' => array(
        array('route_name', 32),
        array('route_param_key', 16),
      ),
    ),
    'primary key' => array('mlid'),
    'unique keys' => array(
      'id' => array('id'),
    ),
  );
 
  return $schema;
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.