function MediaLibraryHooks::mediaTypeFormSubmit

Same name and namespace in other branches
  1. 11.x core/modules/media_library/src/Hook/MediaLibraryHooks.php \Drupal\media_library\Hook\MediaLibraryHooks::mediaTypeFormSubmit()

Submit callback for media type form.

@internal

File

core/modules/media_library/src/Hook/MediaLibraryHooks.php, line 290

Class

MediaLibraryHooks
Hook implementations for media_library.

Namespace

Drupal\media_library\Hook

Code

public function mediaTypeFormSubmit(array &$form, FormStateInterface $form_state) : void {
  $form_object = $form_state->getFormObject();
  if ($form_object->getOperation() === 'add') {
    $type = $form_object->getEntity();
    $form_display_created = MediaLibraryDisplayManager::configureFormDisplay($type);
    $view_display_created = MediaLibraryDisplayManager::configureViewDisplay($type);
    if ($form_display_created || $view_display_created) {
      \Drupal::messenger()->addStatus($this->t('Media Library form and view displays have been created for the %type media type.', [
        '%type' => $type->label(),
      ]));
    }
  }
}

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