You are here

public function EntityBrowserBlock::blockSubmit in Entity Browser Block 8

Overrides BlockPluginTrait::blockSubmit

File

src/Plugin/Block/EntityBrowserBlock.php, line 262

Class

EntityBrowserBlock
Defines a generic entity browser block type.

Namespace

Drupal\entity_browser_block\Plugin\Block

Code

public function blockSubmit($form, FormStateInterface $form_state) {
  $selection = $form_state
    ->getValue([
    'selection',
    'table',
  ], []);
  uasort($selection, function ($a, $b) {
    return SortArray::sortByKeyInt($a, $b, '_weight');
  });
  $entity_ids = [];
  $view_modes = [];
  foreach ($selection as $id => $values) {
    $entity_ids[] = $id;
    $view_modes[$id] = $values['view_mode'];
  }
  $this->configuration['entity_ids'] = $entity_ids;
  $this->configuration['view_modes'] = $view_modes;
}