File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed
Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /**
4+ * @file
5+ * Localgov publications importer install and update hooks.
6+ */
7+
8+ use Drupal\Core\Entity\ContentEntityType;
9+ use Drupal\localgov_publications_importer\Entity\Import;
10+ use Drupal\Core\Config\Config;
11+ use Drupal\Core\Config\FileStorage;
12+
13+ /**
14+ * Install entity definitions for the localgov_publications import entity.
15+ */
16+ function localgov_publications_importer_update_10001(): void {
17+ $entity_definition_update_manager = \Drupal::entityDefinitionUpdateManager();
18+ if (!$entity_definition_update_manager->getEntityType('import')) {
19+ $entity_type = new ContentEntityType([
20+ 'id' => 'import',
21+ 'class' => Import::class,
22+ 'label' => t('import'),
23+ 'base_table' => 'import',
24+ 'entity_keys' => [
25+ 'id' => 'id',
26+ 'uuid' => 'uuid',
27+ ],
28+ ]);
29+ \Drupal::entityDefinitionUpdateManager()->installEntityType($entity_type);
30+ }
31+ }
32+
33+ /**
34+ * Install import admin view.
35+ */
36+ function localgov_publications_importer_update_10002(): void {
37+ $path_to_module = \Drupal::service('extension.path.resolver')->getPath('module', 'localgov_publications_importer');
38+ $config_path = $path_to_module . '/config/install';
39+ $config_storage = new FileStorage($config_path);
40+ $view = \Drupal::service('config.factory')->getEditable('views.view.imports');
41+ assert($view instanceof Config);
42+ if ($view->isNew()) {
43+ $view->setData($config_storage->read('views.view.imports'));
44+ $view->save();
45+ }
46+ }
You can’t perform that action at this time.
0 commit comments