Sort behavior plugins by weight

Created on 6 June 2017, over 7 years ago
Updated 22 January 2025, 14 days ago

Problem/Motivation

Saving a paragraphs type creates configuration for all behavior plugins - even disabled ones.
Like so:

behavior_plugins:
  style:
    group: ''
  grid_layout:
    paragraph_reference_field: ''
    available_grid_layouts: {  }
  lockable: {  }
  primer_background:
    background_image_field: ''

This empty dummy configuration can be invalid. We should get rid of this behavior.

Proposed resolution

Change the saving behavior of paragraphs types. Disabled plugins should have not configuration stored.

Remaining tasks

User interface changes

API changes

Let /** var \Drupal\paragraphs\ParagraphsBehaviorCollection $plugin_collection */.
$plugin_collection->getConfiguration() now only contains keys for enabled plugins, while $plugin_collection->get('<diabled_plugin_id>')->getConfiguration() should still return (the default) valid plugin configuration.

The output arrays of ParagraphsBehaviorCollection::getAll, ParagraphsBehaviorCollection::getEnabled and ParagraphsTypeInterface::getEnabledBehaviorPlugins are now required to be sorted by behavior plugin weight.

The instanceIDs array of a ParagraphsBehaviorCollection is now kept sorted by plugin weight, while the pluginInstances array remains unsorted.

Data model changes

πŸ“Œ Task
Status

Needs work

Version

1.0

Component

Code

Created by

πŸ‡¨πŸ‡­Switzerland VladimirMarko

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024