public function MediaImageUpload::getForm in Entity Browser 8.2
Returns widget form.
Parameters
array $original_form: Entire form bult up to this point. Form elements for widget should generally not be added directly to it but returned from funciton as a separated unit.
\Drupal\Core\Form\FormStateInterface $form_state: Form state object.
array $additional_widget_parameters: Additional parameters that we want to pass to the widget.
Return value
array Form structure.
Overrides Upload::getForm
File
- src/
Plugin/ EntityBrowser/ Widget/ MediaImageUpload.php, line 35
Class
- MediaImageUpload
- Uses upload to create media images.
Namespace
Drupal\entity_browser\Plugin\EntityBrowser\WidgetCode
public function getForm(array &$original_form, FormStateInterface $form_state, array $aditional_widget_parameters) {
/** @var \Drupal\media\MediaTypeInterface $media_type */
if (!$this->configuration['media_type'] || !($media_type = $this->entityTypeManager
->getStorage('media_type')
->load($this->configuration['media_type']))) {
return [
'#markup' => $this
->t('The media type is not configured correctly.'),
];
}
if ($media_type
->getSource()
->getPluginId() != 'image') {
return [
'#markup' => $this
->t('The configured media type is not using the image plugin.'),
];
}
$form = parent::getForm($original_form, $form_state, $aditional_widget_parameters);
$form['upload']['#upload_validators']['file_validate_extensions'] = [
$this->configuration['extensions'],
];
return $form;
}