protected function AddMediaFormBase::processInputValues in Media Directories 2.x
Same name and namespace in other branches
- 8 modules/media_directories_ui/src/Form/AddMediaFormBase.php \Drupal\media_directories_ui\Form\AddMediaFormBase::processInputValues()
- 3.x modules/media_directories_ui/src/Form/AddMediaFormBase.php \Drupal\media_directories_ui\Form\AddMediaFormBase::processInputValues()
Creates media items from source field input values.
Parameters
mixed[] $source_field_values: The values for source fields of the media items.
array $form: The complete form.
\Drupal\Core\Form\FormStateInterface $form_state: The current form state.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
2 calls to AddMediaFormBase::processInputValues()
- FileUploadForm::uploadButtonSubmit in modules/
media_directories_ui/ src/ Form/ FileUploadForm.php - Submit handler for the upload button, inside the managed_file element.
- OEmbedForm::addButtonSubmit in modules/
media_directories_ui/ src/ Form/ OEmbedForm.php - Submit handler for the add button.
1 method overrides AddMediaFormBase::processInputValues()
- MediaCombinedUploadForm::processInputValues in modules/
media_directories_ui/ src/ Form/ MediaCombinedUploadForm.php - Creates media items from source field input values.
File
- modules/
media_directories_ui/ src/ Form/ AddMediaFormBase.php, line 790
Class
- AddMediaFormBase
- Class AddMediaFormBase.
Namespace
Drupal\media_directories_ui\FormCode
protected function processInputValues(array $source_field_values, array $form, FormStateInterface $form_state) {
$media_type = $this
->getMediaType($form_state);
$media_storage = $this->entityTypeManager
->getStorage('media');
$source_field_name = $this
->getSourceFieldName($media_type);
$media = array_map(function ($source_field_value) use ($media_type, $media_storage, $source_field_name, $form_state) {
return $this
->createMediaFromValue($media_type, $media_storage, $source_field_name, $source_field_value, $form_state);
}, $source_field_values);
// Re-key the media items before setting them in the form state.
$form_state
->set('media', array_values($media));
// Save the selected items in the form state so they are remembered when an
// item is removed.
// $form_state->set('current_selection', array_filter(explode(',', $form_state->getValue('current_selection'))));.
$form_state
->setRebuild();
}