function bootstrap_paragraphs_update_8202 in Bootstrap Paragraphs 8.2
Updates Accordion.
File
- ./
bootstrap_paragraphs.install, line 130 - Install, uninstall and update hooks for Bootstrap Paragraphs module.
Code
function bootstrap_paragraphs_update_8202() {
// Sets variable for the path.
$bp_path = drupal_get_path('module', 'bootstrap_paragraphs');
// Create field storage.
$bp_accordion_expand_storage_yml = Yaml::parse(file_get_contents($bp_path . '/config/optional/field.storage.paragraph.bp_accordion_expand.yml'));
if (!FieldStorageConfig::loadByName($bp_accordion_expand_storage_yml['entity_type'], $bp_accordion_expand_storage_yml['field_name'])) {
FieldStorageConfig::create($bp_accordion_expand_storage_yml)
->save();
}
// Create field instance.
$bp_accordion_expand_yml = Yaml::parse(file_get_contents($bp_path . '/config/optional/field.field.paragraph.bp_accordion.bp_accordion_expand.yml'));
if (!FieldConfig::loadByName($bp_accordion_expand_yml['entity_type'], $bp_accordion_expand_yml['bundle'], $bp_accordion_expand_yml['field_name'])) {
FieldConfig::create($bp_accordion_expand_yml)
->save();
}
// Create field storage.
$bp_show_indicators_storage_yml = Yaml::parse(file_get_contents($bp_path . '/config/optional/field.storage.paragraph.bp_show_indicators.yml'));
if (!FieldStorageConfig::loadByName($bp_show_indicators_storage_yml['entity_type'], $bp_show_indicators_storage_yml['field_name'])) {
FieldStorageConfig::create($bp_show_indicators_storage_yml)
->save();
}
// Create field instance.
$bp_show_indicators_yml = Yaml::parse(file_get_contents($bp_path . '/config/optional/field.field.paragraph.bp_accordion.bp_show_indicators.yml'));
if (!FieldConfig::loadByName($bp_show_indicators_yml['entity_type'], $bp_show_indicators_yml['bundle'], $bp_show_indicators_yml['field_name'])) {
FieldConfig::create($bp_show_indicators_yml)
->save();
}
// Create field storage.
$bp_show_button_storage_yml = Yaml::parse(file_get_contents($bp_path . '/config/optional/field.storage.paragraph.bp_show_button.yml'));
if (!FieldStorageConfig::loadByName($bp_show_button_storage_yml['entity_type'], $bp_show_button_storage_yml['field_name'])) {
FieldStorageConfig::create($bp_show_button_storage_yml)
->save();
}
// Create field instance.
$bp_show_button_yml = Yaml::parse(file_get_contents($bp_path . '/config/optional/field.field.paragraph.bp_accordion_section.bp_show_button.yml'));
if (!FieldConfig::loadByName($bp_show_button_yml['entity_type'], $bp_show_button_yml['bundle'], $bp_show_button_yml['field_name'])) {
FieldConfig::create($bp_show_button_yml)
->save();
}
// Updates Accordian form display.
bootstrap_paragraphs_update_entity_from_yml('core.entity_form_display.paragraph.bp_accordion.default', 'entity_form_display', 'paragraph.bp_accordion.default', [
'bp_background' => 'content.bp_background',
'bp_width' => 'content.bp_width',
'bp_accordion_expand' => 'content.bp_accordion_expand',
'bp_show_indicators' => 'content.bp_show_indicators',
'bp_accordion_section' => 'content.bp_accordion_section',
]);
// Updates Accordian Section form display config.
bootstrap_paragraphs_update_entity_from_yml('core.entity_form_display.paragraph.bp_accordion_section.default', 'entity_form_display', 'paragraph.bp_accordion_section.default', [
'bp_show_button' => 'content.bp_show_button',
'bp_accordion_section_title' => 'content.bp_accordion_section_title',
'bp_accordion_section_body' => 'content.bp_accordion_section_body',
]);
// Send message to updater.
$message = t('Adds fields to the Accordion bundle. For more detailed information, visit http://bp.jimbir.ch/updates/8202');
return $message;
}