Version 1
[yaffs-website] / web / core / modules / system / tests / modules / entity_crud_hook_test / entity_crud_hook_test.module
1 <?php
2
3 /**
4  * @file
5  * Test module for the Entity CRUD API.
6  */
7
8 use Drupal\Core\Entity\EntityInterface;
9
10 /**
11  * Implements hook_entity_create().
12  */
13 function entity_crud_hook_test_entity_create(EntityInterface $entity) {
14   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called for type ' . $entity->getEntityTypeId());
15 }
16
17 /**
18  * Implements hook_ENTITY_TYPE_create() for block entities.
19  */
20 function entity_crud_hook_test_block_create() {
21   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
22 }
23
24 /**
25  * Implements hook_ENTITY_TYPE_create() for comment entities.
26  */
27 function entity_crud_hook_test_comment_create() {
28   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
29 }
30
31 /**
32  * Implements hook_ENTITY_TYPE_create() for file entities.
33  */
34 function entity_crud_hook_test_file_create() {
35   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
36 }
37
38 /**
39  * Implements hook_ENTITY_TYPE_create() for node entities.
40  */
41 function entity_crud_hook_test_node_create() {
42   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
43 }
44
45 /**
46  * Implements hook_ENTITY_TYPE_create() for taxonomy_term entities.
47  */
48 function entity_crud_hook_test_taxonomy_term_create() {
49   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
50 }
51
52 /**
53  * Implements hook_ENTITY_TYPE_create() for taxonomy_vocabulary entities.
54  */
55 function entity_crud_hook_test_taxonomy_vocabulary_create() {
56   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
57 }
58
59 /**
60  * Implements hook_ENTITY_TYPE_create() for user entities.
61  */
62 function entity_crud_hook_test_user_create() {
63   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
64 }
65
66 /**
67  * Implements hook_entity_presave().
68  */
69 function entity_crud_hook_test_entity_presave(EntityInterface $entity) {
70   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called for type ' . $entity->getEntityTypeId());
71 }
72
73 /**
74  * Implements hook_ENTITY_TYPE_presave() for block entities.
75  */
76 function entity_crud_hook_test_block_presave() {
77   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
78 }
79
80 /**
81  * Implements hook_ENTITY_TYPE_presave() for comment entities.
82  */
83 function entity_crud_hook_test_comment_presave() {
84   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
85 }
86
87 /**
88  * Implements hook_ENTITY_TYPE_presave() for file entities.
89  */
90 function entity_crud_hook_test_file_presave() {
91   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
92 }
93
94 /**
95  * Implements hook_ENTITY_TYPE_presave() for node entities.
96  */
97 function entity_crud_hook_test_node_presave() {
98   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
99 }
100
101 /**
102  * Implements hook_ENTITY_TYPE_presave() for taxonomy_term entities.
103  */
104 function entity_crud_hook_test_taxonomy_term_presave() {
105   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
106 }
107
108 /**
109  * Implements hook_ENTITY_TYPE_presave() for taxonomy_vocabulary entities.
110  */
111 function entity_crud_hook_test_taxonomy_vocabulary_presave() {
112   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
113 }
114
115 /**
116  * Implements hook_ENTITY_TYPE_presave() for user entities.
117  */
118 function entity_crud_hook_test_user_presave() {
119   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
120 }
121
122 /**
123  * Implements hook_entity_insert().
124  */
125 function entity_crud_hook_test_entity_insert(EntityInterface $entity) {
126   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called for type ' . $entity->getEntityTypeId());
127 }
128
129 /**
130  * Implements hook_ENTITY_TYPE_insert() for block entities.
131  */
132 function entity_crud_hook_test_block_insert() {
133   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
134 }
135
136 /**
137  * Implements hook_ENTITY_TYPE_insert() for comment entities.
138  */
139 function entity_crud_hook_test_comment_insert() {
140   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
141 }
142
143 /**
144  * Implements hook_ENTITY_TYPE_insert() for file entities.
145  */
146 function entity_crud_hook_test_file_insert() {
147   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
148 }
149
150 /**
151  * Implements hook_ENTITY_TYPE_insert() for node entities.
152  */
153 function entity_crud_hook_test_node_insert() {
154   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
155 }
156
157 /**
158  * Implements hook_ENTITY_TYPE_insert() for taxonomy_term entities.
159  */
160 function entity_crud_hook_test_taxonomy_term_insert() {
161   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
162 }
163
164 /**
165  * Implements hook_ENTITY_TYPE_insert() for taxonomy_vocabulary entities.
166  */
167 function entity_crud_hook_test_taxonomy_vocabulary_insert() {
168   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
169 }
170
171 /**
172  * Implements hook_ENTITY_TYPE_insert() for user entities.
173  */
174 function entity_crud_hook_test_user_insert() {
175   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
176 }
177
178 /**
179  * Implements hook_entity_load().
180  */
181 function entity_crud_hook_test_entity_load(array $entities, $type) {
182   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called for type ' . $type);
183 }
184
185 /**
186  * Implements hook_ENTITY_TYPE_load() for block entities.
187  */
188 function entity_crud_hook_test_block_load() {
189   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
190 }
191
192 /**
193  * Implements hook_ENTITY_TYPE_load() for comment entities.
194  */
195 function entity_crud_hook_test_comment_load() {
196   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
197 }
198
199 /**
200  * Implements hook_ENTITY_TYPE_load() for file entities.
201  */
202 function entity_crud_hook_test_file_load() {
203   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
204 }
205
206 /**
207  * Implements hook_ENTITY_TYPE_load() for node entities.
208  */
209 function entity_crud_hook_test_node_load() {
210   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
211 }
212
213 /**
214  * Implements hook_ENTITY_TYPE_load() for taxonomy_term entities.
215  */
216 function entity_crud_hook_test_taxonomy_term_load() {
217   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
218 }
219
220 /**
221  * Implements hook_ENTITY_TYPE_load() for taxonomy_vocabulary entities.
222  */
223 function entity_crud_hook_test_taxonomy_vocabulary_load() {
224   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
225 }
226
227 /**
228  * Implements hook_ENTITY_TYPE_load() for user entities.
229  */
230 function entity_crud_hook_test_user_load() {
231   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
232 }
233
234 /**
235  * Implements hook_entity_update().
236  */
237 function entity_crud_hook_test_entity_update(EntityInterface $entity) {
238   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called for type ' . $entity->getEntityTypeId());
239 }
240
241 /**
242  * Implements hook_ENTITY_TYPE_update() for block entities.
243  */
244 function entity_crud_hook_test_block_update() {
245   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
246 }
247
248 /**
249  * Implements hook_ENTITY_TYPE_update() for comment entities.
250  */
251 function entity_crud_hook_test_comment_update() {
252   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
253 }
254
255 /**
256  * Implements hook_ENTITY_TYPE_update() for file entities.
257  */
258 function entity_crud_hook_test_file_update() {
259   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
260 }
261
262 /**
263  * Implements hook_ENTITY_TYPE_update() for node entities.
264  */
265 function entity_crud_hook_test_node_update() {
266   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
267 }
268
269 /**
270  * Implements hook_ENTITY_TYPE_update() for taxonomy_term entities.
271  */
272 function entity_crud_hook_test_taxonomy_term_update() {
273   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
274 }
275
276 /**
277  * Implements hook_ENTITY_TYPE_update() for taxonomy_vocabulary entities.
278  */
279 function entity_crud_hook_test_taxonomy_vocabulary_update() {
280   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
281 }
282
283 /**
284  * Implements hook_ENTITY_TYPE_update() for user entities.
285  */
286 function entity_crud_hook_test_user_update() {
287   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
288 }
289
290 /**
291  * Implements hook_entity_predelete().
292  */
293 function entity_crud_hook_test_entity_predelete(EntityInterface $entity) {
294   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called for type ' . $entity->getEntityTypeId());
295 }
296
297 /**
298  * Implements hook_ENTITY_TYPE_predelete() for block entities.
299  */
300 function entity_crud_hook_test_block_predelete() {
301   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
302 }
303
304 /**
305  * Implements hook_ENTITY_TYPE_predelete() for comment entities.
306  */
307 function entity_crud_hook_test_comment_predelete() {
308   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
309 }
310
311 /**
312  * Implements hook_ENTITY_TYPE_predelete() for file entities.
313  */
314 function entity_crud_hook_test_file_predelete() {
315   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
316 }
317
318 /**
319  * Implements hook_ENTITY_TYPE_predelete() for node entities.
320  */
321 function entity_crud_hook_test_node_predelete() {
322   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
323 }
324
325 /**
326  * Implements hook_ENTITY_TYPE_predelete() for taxonomy_term entities.
327  */
328 function entity_crud_hook_test_taxonomy_term_predelete() {
329   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
330 }
331
332 /**
333  * Implements hook_ENTITY_TYPE_predelete() for taxonomy_vocabulary entities.
334  */
335 function entity_crud_hook_test_taxonomy_vocabulary_predelete() {
336   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
337 }
338
339 /**
340  * Implements hook_ENTITY_TYPE_predelete() for user entities.
341  */
342 function entity_crud_hook_test_user_predelete() {
343   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
344 }
345
346 /**
347  * Implements hook_entity_delete().
348  */
349 function entity_crud_hook_test_entity_delete(EntityInterface $entity) {
350   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called for type ' . $entity->getEntityTypeId());
351 }
352
353 /**
354  * Implements hook_ENTITY_TYPE_delete() for block entities.
355  */
356 function entity_crud_hook_test_block_delete() {
357   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
358 }
359
360 /**
361  * Implements hook_ENTITY_TYPE_delete() for comment entities.
362  */
363 function entity_crud_hook_test_comment_delete() {
364   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
365 }
366
367 /**
368  * Implements hook_ENTITY_TYPE_delete() for file entities.
369  */
370 function entity_crud_hook_test_file_delete() {
371   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
372 }
373
374 /**
375  * Implements hook_ENTITY_TYPE_delete() for node entities.
376  */
377 function entity_crud_hook_test_node_delete() {
378   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
379 }
380
381 /**
382  * Implements hook_ENTITY_TYPE_delete() for taxonomy_term entities.
383  */
384 function entity_crud_hook_test_taxonomy_term_delete() {
385   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
386 }
387
388 /**
389  * Implements hook_ENTITY_TYPE_delete() for taxonomy_vocabulary entities.
390  */
391 function entity_crud_hook_test_taxonomy_vocabulary_delete() {
392   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
393 }
394
395 /**
396  * Implements hook_ENTITY_TYPE_delete() for user entities.
397  */
398 function entity_crud_hook_test_user_delete() {
399   $GLOBALS['entity_crud_hook_test'][] = (__FUNCTION__ . ' called');
400 }