forked from pdenooijer/hook_event_dispatcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hook_event_dispatcher.module
700 lines (646 loc) · 23.7 KB
/
hook_event_dispatcher.module
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
<?php
/**
* @file
* Hook event dispatcher module.
*/
use Drupal\Core\Asset\AttachedAssetsInterface;
use Drupal\Core\Block\BlockPluginInterface;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\BubbleableMetadata;
use Drupal\Core\Session\AccountInterface;
use Drupal\hook_event_dispatcher\Event\Block\BlockBuildAlterEvent;
use Drupal\hook_event_dispatcher\Event\Cron\CronEvent;
use Drupal\hook_event_dispatcher\Event\Entity\EntityAccessEvent;
use Drupal\hook_event_dispatcher\Event\Entity\EntityCreateEvent;
use Drupal\hook_event_dispatcher\Event\Entity\EntityDeleteEvent;
use Drupal\hook_event_dispatcher\Event\Entity\EntityInsertEvent;
use Drupal\hook_event_dispatcher\Event\Entity\EntityLoadEvent;
use Drupal\hook_event_dispatcher\Event\Entity\EntityPredeleteEvent;
use Drupal\hook_event_dispatcher\Event\Entity\EntityPresaveEvent;
use Drupal\hook_event_dispatcher\Event\Entity\EntityTranslationDeleteEvent;
use Drupal\hook_event_dispatcher\Event\Entity\EntityTranslationInsertEvent;
use Drupal\hook_event_dispatcher\Event\Entity\EntityUpdateEvent;
use Drupal\hook_event_dispatcher\Event\Entity\EntityViewEvent;
use Drupal\hook_event_dispatcher\Event\EntityExtra\EntityExtraFieldInfoAlterEvent;
use Drupal\hook_event_dispatcher\Event\EntityExtra\EntityExtraFieldInfoEvent;
use Drupal\hook_event_dispatcher\Event\EntityField\EntityFieldAccessEvent;
use Drupal\hook_event_dispatcher\Event\EntityType\EntityBaseFieldInfoAlterEvent;
use Drupal\hook_event_dispatcher\Event\EntityType\EntityBaseFieldInfoEvent;
use Drupal\hook_event_dispatcher\Event\EntityType\EntityBundleFieldInfoAlterEvent;
use Drupal\hook_event_dispatcher\Event\EntityType\EntityTypeBuildEvent;
use Drupal\hook_event_dispatcher\Event\Form\FormAlterEvent;
use Drupal\hook_event_dispatcher\Event\Form\FormBaseAlterEvent;
use Drupal\hook_event_dispatcher\Event\Form\FormIdAlterEvent;
use Drupal\hook_event_dispatcher\Event\Form\WidgetFormAlterEvent;
use Drupal\hook_event_dispatcher\Event\Form\WidgetTypeFormAlterEvent;
use Drupal\hook_event_dispatcher\Event\Page\PageBottomEvent;
use Drupal\hook_event_dispatcher\Event\Page\PageTopEvent;
use Drupal\hook_event_dispatcher\Event\Page\PageAttachmentsEvent;
use Drupal\hook_event_dispatcher\Event\Path\PathDeleteEvent;
use Drupal\hook_event_dispatcher\Event\Path\PathInsertEvent;
use Drupal\hook_event_dispatcher\Event\Path\PathUpdateEvent;
use Drupal\hook_event_dispatcher\Event\Theme\JsAlterEvent;
use Drupal\hook_event_dispatcher\Event\Theme\LibraryInfoAlterEvent;
use Drupal\hook_event_dispatcher\Event\Theme\TemplatePreprocessDefaultVariablesAlterEvent;
use Drupal\hook_event_dispatcher\Event\Theme\ThemeEvent;
use Drupal\hook_event_dispatcher\Event\Theme\ThemeSuggestionsAlterEvent;
use Drupal\hook_event_dispatcher\Event\Theme\ThemeSuggestionsAlterIdEvent;
use Drupal\hook_event_dispatcher\Event\Token\TokensInfoEvent;
use Drupal\hook_event_dispatcher\Event\Token\TokensReplacementEvent;
use Drupal\hook_event_dispatcher\Event\Toolbar\ToolbarAlterEvent;
use Drupal\hook_event_dispatcher\Event\User\UserCancelEvent;
use Drupal\hook_event_dispatcher\Event\User\UserCancelMethodsAlterEvent;
use Drupal\hook_event_dispatcher\Event\User\UserFormatNameAlterEvent;
use Drupal\hook_event_dispatcher\Event\User\UserLoginEvent;
use Drupal\hook_event_dispatcher\Event\User\UserLogoutEvent;
use Drupal\hook_event_dispatcher\Event\Views\ViewsDataAlterEvent;
use Drupal\hook_event_dispatcher\Event\Views\ViewsDataEvent;
use Drupal\hook_event_dispatcher\Event\Views\ViewsPostBuildEvent;
use Drupal\hook_event_dispatcher\Event\Views\ViewsPostExecuteEvent;
use Drupal\hook_event_dispatcher\Event\Views\ViewsPreBuildEvent;
use Drupal\hook_event_dispatcher\Event\Views\ViewsPreExecuteEvent;
use Drupal\hook_event_dispatcher\Event\Views\ViewsQueryAlterEvent;
use Drupal\views\Plugin\views\query\QueryPluginBase;
use Drupal\views\ViewExecutable;
/**
* Implements hook_help().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_help($routeName) {
if ($routeName === 'help.page.hook_event_dispatcher') {
$path = \drupal_get_path('module', 'hook_event_dispatcher');
$output = \file_get_contents($path . '/README.md');
return '<pre>' . $output . '</pre>';
}
return '';
}
/**
* Implements hook_entity_insert().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_entity_insert(EntityInterface $entity) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$manager->register(new EntityInsertEvent($entity));
}
/**
* Implements hook_entity_update().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_entity_update(EntityInterface $entity) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$manager->register(new EntityUpdateEvent($entity));
}
/**
* Implements hook_entity_predelete().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_entity_predelete(EntityInterface $entity) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$manager->register(new EntityPredeleteEvent($entity));
}
/**
* Implements hook_entity_delete().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_entity_delete(EntityInterface $entity) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$manager->register(new EntityDeleteEvent($entity));
}
/**
* Implements hook_entity_presave().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_entity_presave(EntityInterface $entity) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$manager->register(new EntityPresaveEvent($entity));
}
/**
* Implements hook_entity_access().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_entity_access(EntityInterface $entity, $operation, AccountInterface $account) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$event = new EntityAccessEvent($entity, $operation, $account);
$manager->register($event);
return $event->getAccessResult();
}
/**
* Implements hook_entity_create().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_entity_create(EntityInterface $entity) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$manager->register(new EntityCreateEvent($entity));
}
/**
* Implements hook_entity_load().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_entity_load(array $entities, $entityTypeId) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$manager->register(new EntityLoadEvent($entities, $entityTypeId));
}
/**
* Implements hook_entity_translation_insert().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_entity_translation_insert(EntityInterface $translation) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$manager->register(new EntityTranslationInsertEvent($translation));
}
/**
* Implements hook_entity_translation_delete().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_entity_translation_delete(EntityInterface $translation) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$manager->register(new EntityTranslationDeleteEvent($translation));
}
/**
* Implements hook_entity_view().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_entity_view(
array &$build,
EntityInterface $entity,
EntityViewDisplayInterface $display,
$viewMode
) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$manager->register(new EntityViewEvent($build, $entity, $display, $viewMode));
}
/**
* Implements hook_form_alter().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_form_alter(&$form, FormStateInterface $formState, $formId) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$manager->register(new FormAlterEvent($form, $formState, $formId));
$buildInfo = $formState->getBuildInfo();
if (!empty($buildInfo['base_form_id'])) {
/* @var \Drupal\hook_event_dispatcher\Event\Form\FormBaseAlterEvent $event */
$manager->register(new FormBaseAlterEvent($form, $formState, $formId, $buildInfo['base_form_id']));
}
$manager->register(new FormIdAlterEvent($form, $formState, $formId));
}
/**
* Implements hook_field_widget_form_alter().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_field_widget_form_alter(&$element, FormStateInterface $formState, $context) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$manager->register(new WidgetFormAlterEvent($element, $formState, $context));
$manager->register(new WidgetTypeFormAlterEvent($element, $formState, $context));
}
/**
* Implements hook_preprocess().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_preprocess(&$variables, $hook) {
/* @var \Drupal\hook_event_dispatcher\Service\PreprocessEventService $service */
$service = \Drupal::service('preprocess_event.service');
$service->createAndDispatchKnownEvents($hook, $variables);
}
/**
* Implements hook_template_preprocess_default_variables_alter().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_template_preprocess_default_variables_alter(&$variables) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$manager->register(new TemplatePreprocessDefaultVariablesAlterEvent($variables));
}
/**
* Implements hook_block_build_alter().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_block_build_alter(&$build, BlockPluginInterface $block) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$manager->register(new BlockBuildAlterEvent($build, $block));
}
/**
* Implements hook_tokens().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_tokens(
$type,
$tokens,
array $data,
array $options,
BubbleableMetadata $bubbleableMetadata
) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$event = new TokensReplacementEvent($type, $tokens, $data, $options, $bubbleableMetadata);
$manager->register($event);
return $event->getReplacementValues();
}
/**
* Implements hook_token_info().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_token_info() {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$event = new TokensInfoEvent();
$manager->register($event);
return [
'types' => $event->getTokenTypes(),
'tokens' => $event->getTokens(),
];
}
/**
* Implements hook_path_insert().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_path_insert($path) {
if (empty($path)) {
return;
}
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$event = new PathInsertEvent($path);
$manager->register($event);
}
/**
* Implements hook_path_update().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_path_update($path) {
if (empty($path)) {
return;
}
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$event = new PathUpdateEvent($path);
$manager->register($event);
}
/**
* Implements hook_path_delete().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_path_delete($path) {
if (empty($path)) {
return;
}
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$event = new PathDeleteEvent($path);
$manager->register($event);
}
/**
* Implements hook_entity_field_access().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_entity_field_access(
$operation,
FieldDefinitionInterface $fieldDefinition,
AccountInterface $account,
FieldItemListInterface $items = NULL
) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$event = new EntityFieldAccessEvent($operation, $fieldDefinition, $account, $items);
$manager->register($event);
return $event->getAccessResult();
}
/**
* Implements hook_entity_base_field_info().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_entity_base_field_info(EntityTypeInterface $entityType) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$event = new EntityBaseFieldInfoEvent($entityType);
$manager->register($event);
return $event->getFields();
}
/**
* Implements hook_entity_base_field_info_alter().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_entity_base_field_info_alter(array &$fields, EntityTypeInterface $entityType) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$event = new EntityBaseFieldInfoAlterEvent($fields, $entityType);
$manager->register($event);
}
/**
* Implements hook_entity_bundle_field_info_alter().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_entity_bundle_field_info_alter(array &$fields, EntityTypeInterface $entityType, $bundle) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$event = new EntityBundleFieldInfoAlterEvent($fields, $entityType, $bundle);
$manager->register($event);
}
/**
* Implements hook_entity_type_build().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_entity_type_build(array &$entityTypes) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$event = new EntityTypeBuildEvent($entityTypes);
$manager->register($event);
}
/**
* Implements hook_views_data().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_views_data() {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$event = new ViewsDataEvent();
$manager->register($event);
return $event->getData();
}
/**
* Implements hook_views_data_alter().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_views_data_alter(array &$data) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$manager->register(new ViewsDataAlterEvent($data));
}
/**
* Implements hook_views_pre_execute().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_views_pre_execute(ViewExecutable $view) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$event = new ViewsPreExecuteEvent($view);
$manager->register($event);
}
/**
* Implements hook_views_post_execute().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_views_post_execute(ViewExecutable $view) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$event = new ViewsPostExecuteEvent($view);
$manager->register($event);
}
/**
* Implements hook_views_pre_build().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_views_pre_build(ViewExecutable $view) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$event = new ViewsPreBuildEvent($view);
$manager->register($event);
}
/**
* Implements hook_views_post_build().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_views_post_build(ViewExecutable $view) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$event = new ViewsPostBuildEvent($view);
$manager->register($event);
}
/**
* Implements hook_views_query_alter().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_views_query_alter(ViewExecutable $view, QueryPluginBase $query) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$event = new ViewsQueryAlterEvent($view, $query);
$manager->register($event);
}
/**
* Implements hook_entity_extra_field_info().
*/
function hook_event_dispatcher_entity_extra_field_info() {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$event = new EntityExtraFieldInfoEvent();
$manager->register($event);
return $event->getFieldInfo();
}
/**
* Implements hook_entity_extra_field_info_alter().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_entity_extra_field_info_alter(array &$info) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$event = new EntityExtraFieldInfoAlterEvent($info);
$manager->register($event);
}
/**
* Implements hook_theme_suggestions_alter().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_theme_suggestions_alter(array &$suggestions, array $variables, $hook) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$manager->register(new ThemeSuggestionsAlterEvent($suggestions, $variables, $hook));
$manager->register(new ThemeSuggestionsAlterIdEvent($suggestions, $variables, $hook));
}
/**
* Implements hook_theme().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_theme(array $existing) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$event = new ThemeEvent($existing);
$manager->register($event);
return $event->getNewThemes();
}
/**
* Implements hook_user_cancel().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_user_cancel(array $edit, AccountInterface $account, $method) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$event = new UserCancelEvent($edit, $account, $method);
$manager->register($event);
}
/**
* Implements hook_user_cancel_methods_alter.
*
* {@inheritdoc}
*/
function hook_event_dispatcher_user_cancel_methods_alter(array &$methods) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$event = new UserCancelMethodsAlterEvent($methods);
$manager->register($event);
}
/**
* Implements hook_user_login().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_user_login(AccountInterface $account) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$event = new UserLoginEvent($account);
$manager->register($event);
}
/**
* Implements hook_user_logout().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_user_logout(AccountInterface $account) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$event = new UserLogoutEvent($account);
$manager->register($event);
}
/**
* Implements hook_user_format_name_alter().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_user_format_name_alter(&$name, AccountInterface $account) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$event = new UserFormatNameAlterEvent($name, $account);
$manager->register($event);
}
/**
* Implements hook_toolbar_alter().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_toolbar_alter(array &$items) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$event = new ToolbarAlterEvent($items);
$manager->register($event);
}
/**
* Implements hook_js_alter().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_js_alter(array &$javascript, AttachedAssetsInterface $assets) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$event = new JsAlterEvent($javascript, $assets);
$manager->register($event);
}
/**
* Implements hook_library_info_alter().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_library_info_alter(array &$libraries, $extension) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$event = new LibraryInfoAlterEvent($libraries, $extension);
$manager->register($event);
}
/**
* Implements hook_page_top().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_page_top(array &$pageTop) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$event = new PageTopEvent($pageTop);
$manager->register($event);
}
/**
* Implements hook_page_bottom().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_page_bottom(array &$pageBottom) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$event = new PageBottomEvent($pageBottom);
$manager->register($event);
}
/**
* Implements hook_page_attachments().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_page_attachments(array &$attachments) {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$event = new PageAttachmentsEvent($attachments);
$manager->register($event);
}
/**
* Implements hook_cron().
*
* {@inheritdoc}
*/
function hook_event_dispatcher_cron() {
/* @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
$manager = \Drupal::service('hook_event_dispatcher.manager');
$event = new CronEvent();
$manager->register($event);
}