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
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | allowed-bundles-3323371-6.patch | 1.41 KB | n.ghunaim |
Issue fork bootstrap_styles-3323371
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:
- 3323371-give-the-allowed
changes, plain diff MR !48
Comments
Comment #2
n.ghunaim commentedComment #3
n.ghunaim commentedComment #6
n.ghunaim commentedComment #7
n.ghunaim commented