/**
* Gets the enabled media type IDs sorted by weight.
*
* @return string[]
* The media type IDs sorted by weight.
*/
protected function getAllowedMediaTypeIdsSorted() { // Get the media type IDs sorted by the user in the settings form.
$sorted_media_type_ids =
$this->
getSetting('media_types'
);
// Get the configured media types from the field storage.
$handler_settings =
$this->
getFieldSetting('handler_settings'
);
// The target bundles will be blank when saving field storage settings,
// when first adding a media reference field.
$allowed_media_type_ids =
$handler_settings['target_bundles'
] ?? NULL;
// When there are no allowed media types, return the empty array.
if ($allowed_media_type_ids ===
[]) { return $allowed_media_type_ids;
} // When no target bundles are configured for the field, all are allowed.
if ($allowed_media_type_ids === NULL
) {