throw new \
InvalidArgumentException('Can only add media types which use a file field as a source field.'
);
} return $media_type;
} /**
* {@inheritdoc}
*/
protected function buildInputElement(array
$form, FormStateInterface
$form_state) { // Create a file item to get the upload validators.
$media_type =
$this->
getMediaType($form_state);
$item =
$this->
createFileItem($media_type);
/** @var \Drupal\media_library\MediaLibraryState $state */
$state =
$this->
getMediaLibraryState($form_state);
if (!
$state->
hasSlotsAvailable()) { return $form;
} $slots =
$state->
getAvailableSlots();
// Add a container to group the input elements for styling purposes.
$form['container'
] =
[