You are here

public function EntityBlock::blockSubmit in Entity Blocks 8

Overrides BlockPluginTrait::blockSubmit

File

src/Plugin/Block/EntityBlock.php, line 140

Class

EntityBlock
Provides the block for similar articles.

Namespace

Drupal\entity_block\Plugin\Block

Code

public function blockSubmit($form, FormStateInterface $form_state) {
  parent::blockSubmit($form, $form_state);
  $this->configuration['entity'] = $form_state
    ->getValue('entity');
  $this->configuration['view_mode'] = $form_state
    ->getValue('view_mode');
  if ($entity = $this->entityStorage
    ->load($this->configuration['entity'])) {
    $plugin_definition = $this
      ->getPluginDefinition();
    $admin_label = $plugin_definition['admin_label'];
    $this->configuration['label'] = new FormattableMarkup('@entity_label (@admin_label)', [
      '@entity_label' => $entity
        ->label(),
      '@admin_label' => $admin_label,
    ]);
  }
}