function MediaLibraryState::create

Same name in other branches
  1. 8.9.x core/modules/media_library/src/MediaLibraryState.php \Drupal\media_library\MediaLibraryState::create()
  2. 10 core/modules/media_library/src/MediaLibraryState.php \Drupal\media_library\MediaLibraryState::create()
  3. 11.x 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.

19 calls to MediaLibraryState::create()
DrupalMediaLibrary::getConfig in core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalMediaLibrary.php
Returns the additions to CKEDITOR.config for a specific CKEditor instance.
MediaLibrary::getDynamicPluginConfig in core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/MediaLibrary.php
Allows a plugin to modify its static configuration.
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.

... 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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.