public function Upload::getForm in Media entity image 8
File
- src/
Plugin/ EntityBrowser/ Widget/ Upload.php, line 35
Class
- Upload
- Uses upload to create media entity images.
Namespace
Drupal\media_entity_image\Plugin\EntityBrowser\WidgetCode
public function getForm(array &$original_form, FormStateInterface $form_state, array $aditional_widget_parameters) {
/** @var \Drupal\media_entity\MediaBundleInterface $bundle */
if (!$this->configuration['media_bundle'] || !($bundle = $this->entityTypeManager
->getStorage('media_bundle')
->load($this->configuration['media_bundle']))) {
return [
'#markup' => $this
->t('The media bundle is not configured correctly.'),
];
}
if ($bundle
->getType()
->getPluginId() != 'image') {
return [
'#markup' => $this
->t('The configured bundle is not using image plugin.'),
];
}
$form = parent::getForm($original_form, $form_state, $aditional_widget_parameters);
$form['upload']['#upload_validators']['file_validate_extensions'] = [
$this->configuration['extensions'],
];
return $form;
}