public function MediaEntityDropzoneJsEbWidget::prepareEntities in DropzoneJS 8.2
Same name and namespace in other branches
- 8 modules/eb_widget/src/Plugin/EntityBrowser/Widget/MediaEntityDropzoneJsEbWidget.php \Drupal\dropzonejs_eb_widget\Plugin\EntityBrowser\Widget\MediaEntityDropzoneJsEbWidget::prepareEntities()
Overrides DropzoneJsEbWidget::prepareEntities
2 calls to MediaEntityDropzoneJsEbWidget::prepareEntities()
- InlineEntityFormMediaWidget::submitEdit in modules/
eb_widget/ src/ Plugin/ EntityBrowser/ Widget/ InlineEntityFormMediaWidget.php - Submit callback for the edit button.
- MediaEntityDropzoneJsEbWidget::submit in modules/
eb_widget/ src/ Plugin/ EntityBrowser/ Widget/ MediaEntityDropzoneJsEbWidget.php
File
- modules/
eb_widget/ src/ Plugin/ EntityBrowser/ Widget/ MediaEntityDropzoneJsEbWidget.php, line 132
Class
- MediaEntityDropzoneJsEbWidget
- Provides an Entity Browser widget that uploads media entities.
Namespace
Drupal\dropzonejs_eb_widget\Plugin\EntityBrowser\WidgetCode
public function prepareEntities(array $form, FormStateInterface $form_state) {
$entities = [];
$media_type = $this
->getType();
foreach (parent::prepareEntities($form, $form_state) as $file) {
$entities[] = $this->entityTypeManager
->getStorage('media')
->create([
'bundle' => $media_type
->id(),
$media_type
->getSource()
->getConfiguration()['source_field'] => $file,
'uid' => $this->currentUser
->id(),
'status' => TRUE,
'type' => $media_type
->getSource()
->getPluginId(),
]);
}
return $entities;
}