-
Notifications
You must be signed in to change notification settings - Fork 0
/
fragaria.install
41 lines (36 loc) · 1.39 KB
/
fragaria.install
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
<?php
use Drupal\Core\Config\Entity\ConfigEntityType;
use Drupal\Core\StringTranslation\TranslatableMarkup;
/**
* Implements hook_install().
*
* Installs fragariaredirect_entity config entity for dynamic routing redirects.
*
* @see 'https://www.drupal.org/node/3034742'
*/
function fragaria_install() {
$entity_type_manager = \Drupal::entityTypeManager();
$entity_type_manager->clearCachedDefinitions();
$entity_type = $entity_type_manager->getDefinition('fragariaredirect_entity');
\Drupal::entityDefinitionUpdateManager()->installEntityType($entity_type);
}
function fragaria_update_10001() {
$message = "Nothing to update. Fragaria Entity is not installed.";
$entity_type = \Drupal::entityDefinitionUpdateManager()->getEntityType('fragariaredirect_entity');
if ($entity_type) {
$entity_config_export = $entity_type->get('config_export');
$entity_config_export[] = 'do_replacement';
$entity_type->set('config_export', $entity_config_export);
\Drupal::entityDefinitionUpdateManager()->updateEntityType($entity_type);
$message = "Fragaria Entity's Schema updated with do_replacement setting";
}
return $message;
}
/**
* Implements hook_uninstall().
*/
function fragaria_uninstall() {
\Drupal::entityDefinitionUpdateManager()
->uninstallEntityType(\Drupal::entityTypeManager()->getDefinition('fragariaredirect_entity'));
return t('Removing fragariaredirect_entity');
}