Remove unwanted fences overwrites in admin settings form build

Created on 9 August 2023, over 1 year ago

Problem/Motivation

In
https://git.drupalcode.org/issue/photoswipe-3232070/-/commit/719e4c31b66...

The following code was added into the admin settings form build:

  public function buildForm(array $form, FormStateInterface $form_state) {
    $config = $this->configFactory->get('photoswipe.settings');
    if ($view_displays = \Drupal::entityTypeManager()->getStorage('entity_view_display')->loadMultiple(NULL)) {
      // Loop through all entity view displays:
      foreach ($view_displays as $view_display) {
        $components = $view_display->getComponents();
        foreach ($components as $componentName => $component) {
          if (!in_array($component['type'], [
            'photoswipe_field_formatter',
            'photoswipe_responsive_field_formatter',
          ])) {
            // None of our formatters are used, skip this component:
            continue;
          }
          if (!empty($component['third_party_settings']['fences'])) {
            // Explicitely set fences_field_items_wrapper_tag to 'none' if not existing yet.
            if (!isset($component['third_party_settings']['fences']['fences_field_items_wrapper_tag'])) {
              $component['third_party_settings']['fences']['fences_field_items_wrapper_tag'] = TagManagerInterface::NO_MARKUP_VALUE;
            }
            // Explicitely set fences_field_items_wrapper_classes to 'none' if not existing yet.
            if (!isset($component['third_party_settings']['fences']['fences_field_items_wrapper_classes'])) {
              $component['third_party_settings']['fences']['fences_field_items_wrapper_classes'] = TagManagerInterface::NO_MARKUP_VALUE;
            }
            // Save changes:
            $view_display->setComponent($componentName, $component)->save();
          }
        }
      }
    }

I have no clue how and why that happened, but it shouldn't :D Let's please remove that immediately :D

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

5.0

Component

Code

Created by

🇩🇪Germany Anybody Porta Westfalica

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024