public function Upload::buildConfigurationForm in Media entity audio 8.2
Same name and namespace in other branches
- 8 src/Plugin/EntityBrowser/Widget/Upload.php \Drupal\media_entity_audio\Plugin\EntityBrowser\Widget\Upload::buildConfigurationForm()
File
- src/
Plugin/ EntityBrowser/ Widget/ Upload.php, line 93
Class
- Upload
- Uses upload to create media entity audios.
Namespace
Drupal\media_entity_audio\Plugin\EntityBrowser\WidgetCode
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$bundle_options = [];
$form = parent::buildConfigurationForm($form, $form_state);
$form['extensions'] = [
'#type' => 'textfield',
'#title' => $this
->t('Allowed extensions'),
'#default_value' => $this->configuration['extensions'],
'#required' => TRUE,
];
$bundles = $this->entityTypeManager
->getStorage('media_bundle')
->loadByProperties([
'type' => 'audio',
]);
/** @var \Drupal\media_entity\MediaBundleInterface $bundle */
foreach ($bundles as $bundle) {
$bundle_options[$bundle
->id()] = $bundle
->label();
}
if (empty($bundle_options)) {
$url = Url::fromRoute('media.bundle_add')
->toString();
$form['media bundle'] = [
'#markup' => $this
->t("You don't have media bundle of the Audio type. You should <a href='!link'>create one</a>", [
'!link' => $url,
]),
];
}
else {
$form['media bundle'] = [
'#type' => 'select',
'#title' => $this
->t('Media bundle'),
'#default_value' => $this->configuration['media bundle'],
'#options' => $bundle_options,
];
}
return $form;
}