-
Notifications
You must be signed in to change notification settings - Fork 1
/
wmmeta.module
62 lines (53 loc) · 1.68 KB
/
wmmeta.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
<?php
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\wmmeta\Event\MetaFormAlterEvent;
use Drupal\wmmeta\WmmetaEvents;
function wmmeta_cron(): void
{
\Drupal::getContainer()->get('wmmeta.scheduler')->runSchedule();
}
function wmmeta_theme()
{
return [
'meta_head_tags' => [
'variables' => [
'meta' => \Drupal::getContainer()->get('wmmeta.meta')->getDefaultMetaData(),
],
'path' => \Drupal::getContainer()->get('extension.path.resolver')->getPath('module', 'wmmeta') . DIRECTORY_SEPARATOR . 'templates',
'template' => 'head_tags',
],
];
}
function wmmeta_preprocess_html(&$variables): void
{
\Drupal::getContainer()
->get('wmmeta.schema_org.manager')
->onPreprocessHtml($variables);
$variables['metaHeadTags'] = [
'#theme' => 'meta_head_tags',
'#meta' => \Drupal::getContainer()->get('wmmeta.meta')->getMetaData(),
];
}
function wmmeta_inline_entity_form_entity_form_alter(&$entityForm, FormStateInterface $formState): void
{
if ($entityForm['#entity_type'] !== 'meta') {
return;
}
Drupal::getContainer()->get('event_dispatcher')
->dispatch(new MetaFormAlterEvent($entityForm, $formState), WmmetaEvents::META_FORM_ALTER);
}
function wmmeta_entity_presave(EntityInterface $entity): void
{
\Drupal::service('wmmeta.scheduler.subscriber')
->setEntityStatus($entity);
}
/**
* Implements @see hook_entity_type_alter().
*/
function wmmeta_entity_type_alter(array &$entityTypes): void
{
if (isset($entityTypes['meta'])) {
$entityTypes['meta']->addConstraint('timeframe_constraint');
}
}