-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlocalgov_page_components.install
65 lines (55 loc) · 1.79 KB
/
localgov_page_components.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
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
<?php
/**
* @file
* LocalGovDrupal page components install file.
*/
use Drupal\localgov_core\FieldRenameHelper;
/**
* Update Field names in localgov page components.
*
* Field mapping between existing and new names:
* field_page_components => localgov_page_components.
*
* This change creates and updates Drupal config entities. Unless configuration
* is *exported* after this update, later calls to 'drush deploy' or similar
* will revert these changes.
*/
function localgov_page_components_update_8001(&$sandbox) {
// Update field_ types fields provided by localgov_page_components.
FieldRenameHelper::renameField('field_page_components', 'localgov_page_components', 'node');
return t('Please export your sites configuration! Config entities for localgov_page_components where updated.');
}
/**
* Implements hook_install().
*/
function localgov_page_components_install($is_syncing) {
if ($is_syncing) {
return;
}
/** @var \Drupal\linkit\ProfileInterface $defaultLinkItProfile */
$defaultLinkItProfile = \Drupal::service('entity_type.manager')->getStorage('linkit_profile')->load('default');
if (is_null($defaultLinkItProfile)) {
// Applies during test runs.
return;
}
foreach ($defaultLinkItProfile->getMatchers() as $matcher) {
if ($matcher->getPluginId() == 'entity:paragraphs_library_item') {
return;
}
}
$defaultLinkItProfile->addMatcher([
'id' => 'entity:paragraphs_library_item',
'weight' => 0,
'settings' => [
'metadata' => '',
'bundles' => [
'localgov_contact' => 'localgov_contact',
'localgov_link' => 'localgov_link',
],
'group_by_bundle' => TRUE,
'substitution_type' => 'paragraphs_library_item_localgovdrupal',
'limit' => 20,
],
]);
$defaultLinkItProfile->save();
}