You are here

protected function DirectoryBrowser::prepareEntities in Media Directories 8

Same name and namespace in other branches
  1. 3.x modules/media_directories_ui/src/Plugin/EntityBrowser/Widget/DirectoryBrowser.php \Drupal\media_directories_ui\Plugin\EntityBrowser\Widget\DirectoryBrowser::prepareEntities()
  2. 2.x modules/media_directories_ui/src/Plugin/EntityBrowser/Widget/DirectoryBrowser.php \Drupal\media_directories_ui\Plugin\EntityBrowser\Widget\DirectoryBrowser::prepareEntities()
1 call to DirectoryBrowser::prepareEntities()
DirectoryBrowser::submit in modules/media_directories_ui/src/Plugin/EntityBrowser/Widget/DirectoryBrowser.php

File

modules/media_directories_ui/src/Plugin/EntityBrowser/Widget/DirectoryBrowser.php, line 329

Class

DirectoryBrowser
Uses a view to provide entity listing in a browser's widget.

Namespace

Drupal\media_directories_ui\Plugin\EntityBrowser\Widget

Code

protected function prepareEntities(array $form, FormStateInterface $form_state) {
  $selected_rows = array_values(array_filter($form_state
    ->getUserInput()['entity_browser_select']));
  $entities = [];
  foreach ($selected_rows as $row) {
    list($type, $id) = explode(':', $row);
    $storage = $this->entityTypeManager
      ->getStorage($type);
    if ($entity = $storage
      ->load($id)) {
      $entities[] = $entity;
    }
  }
  return $entities;
}