You are here

public static function MediaLibraryState::create in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/media_library/src/MediaLibraryState.php \Drupal\media_library\MediaLibraryState::create()

Creates a new MediaLibraryState object.

Parameters

string $opener_id: The opener ID.

string[] $allowed_media_type_ids: The allowed media type IDs.

string $selected_type_id: The selected media type ID.

int $remaining_slots: The number of remaining items the user is allowed to select or add in the library.

array $opener_parameters: (optional) Any additional opener-specific parameter values.

Return value

static A state object.

18 calls to MediaLibraryState::create()
DrupalMediaLibrary::getConfig in core/modules/media_library/src/Plugin/CKEditorPlugin/DrupalMediaLibrary.php
Returns the additions to CKEDITOR.config for a specific CKEditor instance.
MediaLibraryAccessTest::testAddFormAccess in core/modules/media_library/tests/src/Kernel/MediaLibraryAccessTest.php
Tests that the media library respects arbitrary access to the add form.
MediaLibraryAccessTest::testEditorOpenerAccess in core/modules/media_library/tests/src/Kernel/MediaLibraryAccessTest.php
@covers \Drupal\media_library\MediaLibraryEditorOpener::checkAccess
MediaLibraryAccessTest::testFieldWidgetEntityCreateAccess in core/modules/media_library/tests/src/Kernel/MediaLibraryAccessTest.php
Tests that the field widget opener respects entity creation permissions.
MediaLibraryAccessTest::testFieldWidgetEntityEditAccess in core/modules/media_library/tests/src/Kernel/MediaLibraryAccessTest.php
Tests that the field widget opener respects entity-specific access.

... See full list

File

core/modules/media_library/src/MediaLibraryState.php, line 74

Class

MediaLibraryState
A value object for the media library state.

Namespace

Drupal\media_library

Code

public static function create($opener_id, array $allowed_media_type_ids, $selected_type_id, $remaining_slots, array $opener_parameters = []) {
  $state = new static([
    'media_library_opener_id' => $opener_id,
    'media_library_allowed_types' => $allowed_media_type_ids,
    'media_library_selected_type' => $selected_type_id,
    'media_library_remaining' => $remaining_slots,
    'media_library_opener_parameters' => $opener_parameters,
  ]);
  return $state;
}