Skip to content

Commit

Permalink
Improve
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Fritsch committed Dec 18, 2023
1 parent f97fb84 commit 2bcd57f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 244 deletions.
232 changes: 0 additions & 232 deletions config/update/thunder_post_update_0001_upgrade_to_thunder7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -301,92 +301,16 @@ system.theme:
admin: gin
core.entity_form_display.media.gallery.default:
expected_config:
content:
field_media_images:
settings:
entity_browser: multiple_image_browser
field_widget_display: rendered_entity
field_widget_display_settings:
view_mode: thumbnail
field_widget_edit: true
field_widget_remove: true
field_widget_replace: false
open: true
selection_mode: selection_edit
type: entity_browser_entity_reference
third_party_settings:
field_group:
group_basis:
label: Basis
update_actions:
delete:
content:
field_media_images:
settings:
entity_browser: multiple_image_browser
field_widget_display: rendered_entity
field_widget_display_settings: true
field_widget_edit: true
field_widget_remove: true
field_widget_replace: false
open: true
selection_mode: selection_edit
change:
content:
field_media_images:
settings:
add_button_text: 'Select images'
check_selected: true
form_mode: override
media_types: { }
no_edit_on_create: true
multi_edit_on_create: false
replace_checkbox_by_order_indicator: true
type: media_library_media_modify_widget
third_party_settings:
field_group:
group_basis:
label: ''
core.entity_form_display.media.gallery.inline:
expected_config:
content:
field_media_images:
settings:
entity_browser: multiple_image_browser
field_widget_display: rendered_entity
field_widget_display_settings:
view_mode: thumbnail
field_widget_edit: true
field_widget_remove: true
field_widget_replace: false
open: true
selection_mode: selection_edit
type: entity_browser_entity_reference
update_actions:
delete:
content:
field_media_images:
settings:
entity_browser: multiple_image_browser
field_widget_display: rendered_entity
field_widget_display_settings: true
field_widget_edit: true
field_widget_remove: true
field_widget_replace: false
open: true
selection_mode: selection_edit
change:
content:
field_media_images:
settings:
add_button_text: 'Select images'
check_selected: true
form_mode: override
media_types: { }
no_edit_on_create: true
multi_edit_on_create: false
replace_checkbox_by_order_indicator: true
type: media_library_media_modify_widget
core.entity_form_display.media.image.default:
expected_config:
third_party_settings:
Expand Down Expand Up @@ -481,20 +405,6 @@ core.entity_form_display.node.article.bulk_edit:
weight: 10
core.entity_form_display.node.article.default:
expected_config:
content:
field_teaser_media:
settings:
entity_browser: image_browser
field_widget_display: rendered_entity
field_widget_display_settings:
view_mode: thumbnail
field_widget_edit: true
field_widget_remove: true
field_widget_replace: false
open: true
selection_mode: selection_append
third_party_settings: { }
type: entity_browser_entity_reference
third_party_settings:
field_group:
group_basis:
Expand All @@ -506,18 +416,6 @@ core.entity_form_display.node.article.default:
group_teaser:
label: Teaser
update_actions:
delete:
content:
field_teaser_media:
settings:
entity_browser: image_browser
field_widget_display: rendered_entity
field_widget_display_settings: true
field_widget_edit: true
field_widget_remove: true
field_widget_replace: false
open: true
selection_mode: selection_append
add:
third_party_settings:
field_group:
Expand All @@ -531,29 +429,6 @@ core.entity_form_display.node.article.default:
format_settings:
show_empty_fields: false
change:
content:
field_teaser_media:
settings:
add_button_text: 'Select image'
check_selected: false
form_mode: override
media_types: { }
no_edit_on_create: false
multi_edit_on_create: false
replace_checkbox_by_order_indicator: false
third_party_settings:
entity_reference_actions:
enabled: false
options:
action_title: Action
include_exclude: exclude
selected_actions:
media_delete_action: '0'
media_edit_action: '0'
media_publish_action: '0'
media_save_action: '0'
media_unpublish_action: '0'
type: media_library_media_modify_widget
third_party_settings:
field_group:
group_basis:
Expand Down Expand Up @@ -593,113 +468,6 @@ core.entity_form_display.node.page.default:
group_paragraphs:
label: ''
weight: 1
core.entity_form_display.paragraph.image.default:
expected_config:
content:
field_image:
settings:
entity_browser: image_browser
field_widget_display: rendered_entity
field_widget_display_settings:
view_mode: thumbnail
field_widget_edit: true
field_widget_remove: true
field_widget_replace: false
open: true
selection_mode: selection_append
third_party_settings: { }
type: entity_browser_entity_reference
update_actions:
delete:
content:
field_image:
settings:
entity_browser: image_browser
field_widget_display: rendered_entity
field_widget_display_settings: true
field_widget_edit: true
field_widget_remove: true
field_widget_replace: false
open: true
selection_mode: selection_append
change:
content:
field_image:
settings:
add_button_text: 'Select image'
check_selected: false
form_mode: override
media_types: { }
no_edit_on_create: false
multi_edit_on_create: false
replace_checkbox_by_order_indicator: false
third_party_settings:
entity_reference_actions:
enabled: false
options:
action_title: Action
include_exclude: exclude
selected_actions:
media_delete_action: '0'
media_edit_action: '0'
media_publish_action: '0'
media_save_action: '0'
media_unpublish_action: '0'
type: media_library_media_modify_widget
core.entity_form_display.paragraph.video.default:
expected_config:
content:
field_video:
settings:
entity_browser: video_browser
field_widget_display: rendered_entity
field_widget_display_settings:
view_mode: thumbnail
field_widget_edit: true
field_widget_remove: true
field_widget_replace: false
open: true
selection_mode: selection_append
third_party_settings: { }
type: entity_browser_entity_reference
update_actions:
delete:
content:
field_video:
settings:
entity_browser: video_browser
field_widget_display: rendered_entity
field_widget_display_settings:
view_mode: thumbnail
field_widget_edit: true
field_widget_remove: true
field_widget_replace: false
open: true
selection_mode: selection_append
change:
content:
field_video:
settings:
add_button_text: 'Select video'
check_selected: false
form_mode: override
media_types: { }
no_edit_on_create: false
multi_edit_on_create: false
replace_checkbox_by_order_indicator: false
third_party_settings:
entity_reference_actions:
enabled: false
options:
action_title: Action
include_exclude: exclude
selected_actions:
media_delete_action: '0'
media_edit_action: '0'
media_publish_action: '0'
media_save_action: '0'
media_unpublish_action: '0'
type: media_library_media_modify_widget
core.entity_view_display.media.gallery.paragraph_preview:
expected_config:
content:
Expand Down
30 changes: 18 additions & 12 deletions thunder.post_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,24 @@ function thunder_post_update_0001_upgrade_to_thunder7(array &$sandbox): string {
/** @var \Drupal\Core\Field\FieldDefinitionInterface $field_definition */
$field_definition = $field_definitions[$component_name];
if ($component['type'] === 'entity_browser_entity_reference') {
$entity_form_display->setComponent($component_name, [
'type' => 'media_library_media_modify_widget',
'weight' => $component['weight'],
'settings' => [
'add_button_text' => 'Add media',
'check_selected' => $field_definition->getFieldStorageDefinition()->getCardinality() !== 1,
'form_mode' => 'override',
'no_edit_on_create' => $field_definition->getFieldStorageDefinition()->getCardinality() !== 1,
'multi_edit_on_create' => FALSE,
'replace_checkbox_by_order_indicator' => $field_definition->getFieldStorageDefinition()->getCardinality() !== 1,
],
]);
$target_bundles = $field_definition->getSetting('handler_settings')['target_bundles'];
$label = 'media';
if (count($target_bundles) === 1) {
$target_type = $field_definition->getFieldStorageDefinition()->getSetting('target_type');
$bundle_entity_type = \Drupal::entityTypeManager()->getDefinition($target_type)->getBundleEntityType();
$bundle_entity = \Drupal::entityTypeManager()->getStorage($bundle_entity_type)->load(reset($target_bundles));
$label = strtolower($bundle_entity->label());
}
$component['type'] = 'media_library_media_modify_widget';
$component['settings'] = [
'add_button_text' => $field_definition->getFieldStorageDefinition()->getCardinality() !== 1 ? 'Add ' . $label . 's' : 'Add ' . $label,
'check_selected' => $field_definition->getFieldStorageDefinition()->getCardinality() !== 1,
'form_mode' => 'override',
'no_edit_on_create' => $field_definition->getFieldStorageDefinition()->getCardinality() !== 1,
'multi_edit_on_create' => FALSE,
'replace_checkbox_by_order_indicator' => $field_definition->getFieldStorageDefinition()->getCardinality() !== 1,
];
$entity_form_display->setComponent($component_name, $component);
}
$entity_form_display->save();
}
Expand Down

0 comments on commit 2bcd57f

Please sign in to comment.