You are here

public function ImageEmbedBlock::blockForm in File Entity Browser 8

Overrides BlockPluginTrait::blockForm

File

src/Plugin/Block/ImageEmbedBlock.php, line 34

Class

ImageEmbedBlock
Provides the "Image Embed" block.

Namespace

Drupal\file_browser\Plugin\Block

Code

public function blockForm($form, FormStateInterface $form_state) {
  $entities = $form_state
    ->getValue([
    'settings',
    'selection',
    'fids',
    'entities',
  ], []);
  $table = $form_state
    ->getValue([
    'settings',
    'selection',
    'table',
  ], []);
  $files = [];
  foreach ($entities as $entity) {
    $settings = isset($table[$entity
      ->id()]) ? $table[$entity
      ->id()] : [];
    $settings['fid'] = $entity
      ->id();
    $files[] = $settings;
  }
  if (empty($files)) {
    $files = $this->configuration['files'];
  }
  $form['selection'] = $this
    ->browserForm($files);
  $form['image_style'] = [
    '#type' => 'select',
    '#options' => image_style_options(),
    '#title' => $this
      ->t('Image style'),
    '#default_value' => $this->configuration['image_style'],
  ];
  return $form;
}