You are here

protected function AddFormBase::getMediaLibraryState in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/media_library/src/Form/AddFormBase.php \Drupal\media_library\Form\AddFormBase::getMediaLibraryState()
  2. 9 core/modules/media_library/src/Form/AddFormBase.php \Drupal\media_library\Form\AddFormBase::getMediaLibraryState()

Get the media library state from the form state.

Parameters

\Drupal\Core\Form\FormStateInterface $form_state: The current form state.

Return value

\Drupal\media_library\MediaLibraryState The media library state.

Throws

\InvalidArgumentException If the media library state is not present in the form state.

4 calls to AddFormBase::getMediaLibraryState()
AddFormBase::buildForm in core/modules/media_library/src/Form/AddFormBase.php
Form constructor.
AddFormBase::buildMediaLibraryUi in core/modules/media_library/src/Form/AddFormBase.php
Build the render array of the media library UI.
AddFormBase::getMediaType in core/modules/media_library/src/Form/AddFormBase.php
Get the media type from the form state.
AddFormBase::updateWidget in core/modules/media_library/src/Form/AddFormBase.php
AJAX callback to send the new media item(s) to the calling code.

File

core/modules/media_library/src/Form/AddFormBase.php, line 776

Class

AddFormBase
Provides a base class for creating media items from within the media library.

Namespace

Drupal\media_library\Form

Code

protected function getMediaLibraryState(FormStateInterface $form_state) {
  $state = $form_state
    ->get('media_library_state');
  if (!$state) {
    throw new \InvalidArgumentException('The media library state is not present in the form state.');
  }
  return $state;
}