Problem/Motivation

The Given #allowed_bundles value for the media library field in BackgroundMedia.php:
'#allowed_bundles' => [$config->get('background_local_video.bundle')],
is not correct which leads to making this module not working with other modules like media library extend, and prevents opening the dialog when clicking Add media button inside section configuration and throwing this error:

layout builder InvalidArgumentException: The allowed types parameter is required and must be an array of strings. in Drupal\media_library\MediaLibrary State->validateRequire Parameters()

Steps to reproduce

1- Install media library extend and enable it.
2- Navigate to the layout page then click the section configuration icon.
3- Click on Styles -> Background -> Background image/Background video -> Add media.
4- Observe the results the media library widget will not open, otherwise the installed module not cause any issues with any other media library field except here.

Proposed resolution

Suggest making the format of the saved value for the #allowed_bundles similar to how the media library core module handles this. as it saved the same bundle for key and value example:

#allowed_bundles [
  image => "image"
]

and in bootstrap_styles module, this file BackgroundMedia.php saved it like

#allowed_bundles [
  0 => "image"
]

So we need to replace this line
'#allowed_bundles' => [$config->get('background_local_video.bundle')],
with

'#allowed_bundles' => [$config->get('background_local_video.bundle') => $config->get('background_local_video.bundle')],

to get the same format as the media library core module.

**Changing the format of how the value is saved will prevent this module to be conflicting with any other contributed modules.

Remaining tasks

Testing to ensure no regression

User interface changes

N/A

API changes

N/A

Data model changes

N/A

CommentFileSizeAuthor
#6 allowed-bundles-3323371-6.patch1.41 KBn.ghunaim
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

n.ghunaim created an issue. See original summary.

n.ghunaim’s picture

Issue summary: View changes
n.ghunaim’s picture

Issue summary: View changes

n.ghunaim’s picture

StatusFileSize
new1.41 KB
n.ghunaim’s picture

Status: Active » Needs review