You are here

protected function InlineEntityFormMediaWidget::prepareEntitiesFromForm in DropzoneJS 8.2

Same name and namespace in other branches
  1. 8 modules/eb_widget/src/Plugin/EntityBrowser/Widget/InlineEntityFormMediaWidget.php \Drupal\dropzonejs_eb_widget\Plugin\EntityBrowser\Widget\InlineEntityFormMediaWidget::prepareEntitiesFromForm()

Prepares entities from the form.

Parameters

array $form: The form.

\Drupal\Core\Form\FormStateInterface $form_state: The form state.

Return value

\Drupal\media\MediaInterface[] The prepared media entities.

1 call to InlineEntityFormMediaWidget::prepareEntitiesFromForm()
InlineEntityFormMediaWidget::submit in modules/eb_widget/src/Plugin/EntityBrowser/Widget/InlineEntityFormMediaWidget.php

File

modules/eb_widget/src/Plugin/EntityBrowser/Widget/InlineEntityFormMediaWidget.php, line 188

Class

InlineEntityFormMediaWidget
Provides an Entity Browser widget that uploads and edit new files.

Namespace

Drupal\dropzonejs_eb_widget\Plugin\EntityBrowser\Widget

Code

protected function prepareEntitiesFromForm(array $form, FormStateInterface $form_state) {
  $media_entities = [];
  foreach (Element::children($form['widget']['entities']) as $key) {

    /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
    $entity = $form['widget']['entities'][$key]['#entity'];
    $inline_entity_form_handler = InlineEntityForm::getInlineFormHandler($entity
      ->getEntityTypeId());
    $inline_entity_form_handler
      ->entityFormSubmit($form['widget']['entities'][$key], $form_state);
    $media_entities[] = $entity;
  }
  return $media_entities;
}