diff --git a/core/modules/media_library/src/MediaLibraryState.php b/core/modules/media_library/src/MediaLibraryState.php index df075640a9..e2059e86cf 100644 --- a/core/modules/media_library/src/MediaLibraryState.php +++ b/core/modules/media_library/src/MediaLibraryState.php @@ -34,6 +34,14 @@ */ class MediaLibraryState extends ParameterBag { + /** + * {@inheritdoc} + */ + public function __construct(array $parameters = []) { + parent::__construct($parameters); + static::validateParameters($this->get('media_library_opener_id'), $this->get('media_library_allowed_types'), $this->get('media_library_selected_type'), $this->get('media_library_remaining')); + } + /** * Creates a new MediaLibraryState object. * @@ -51,7 +59,6 @@ class MediaLibraryState extends ParameterBag { * A state object. */ public static function create($opener_id, array $allowed_media_type_ids, $selected_type_id, $remaining_slots) { - static::validateParameters($opener_id, $allowed_media_type_ids, $selected_type_id, $remaining_slots); return new static([ 'media_library_opener_id' => $opener_id, 'media_library_allowed_types' => $allowed_media_type_ids, diff --git a/core/modules/media_library/src/Plugin/Field/FieldWidget/MediaLibraryWidget.php b/core/modules/media_library/src/Plugin/Field/FieldWidget/MediaLibraryWidget.php index befbbbb017..1c62655429 100644 --- a/core/modules/media_library/src/Plugin/Field/FieldWidget/MediaLibraryWidget.php +++ b/core/modules/media_library/src/Plugin/Field/FieldWidget/MediaLibraryWidget.php @@ -667,6 +667,8 @@ protected static function setFieldState(array $element, FormStateInterface $form * * @return string|null * The field ID or NULL if the opener ID is not valid for the widget. + * + * @see \Drupal\media_library\MediaLibraryState */ public static function getOpenerFieldId($opener_id) { // Media library widget opener IDs are always prefixed with 'field:' in .