You are here

public function WSDataBlock::blockSubmit in Web Service Data 8

Same name and namespace in other branches
  1. 2.0.x modules/wsdata_block/src/Plugin/Block/WSDataBlock.php \Drupal\wsdata_block\Plugin\Block\WSDataBlock::blockSubmit()

Overrides BlockPluginTrait::blockSubmit

File

modules/wsdata_block/src/Plugin/Block/WSDataBlock.php, line 84

Class

WSDataBlock
Provides a 'Green House Gas Emissions' block.

Namespace

Drupal\wsdata_block\Plugin\Block

Code

public function blockSubmit($form, FormStateInterface $form_state) {
  $this->configuration['wscall'] = $form_state
    ->getValue('wscall');

  // Loop thru the replacements and save them as an array.
  $replacement = [];

  /* TODO: replace this workflow, this should be all done through the server
     and not the config entities directly. */
  $wscall = $this->entityTypeManager
    ->getStorage('wscall')
    ->load($this->configuration['wscall']);
  foreach ($wscall
    ->getReplacements() as $rep) {
    $replacement[$rep] = $form_state
      ->getValue('replacements')[$rep];
  }
  $this->configuration['replacements'] = $replacement;
  $this->configuration['data'] = $form_state
    ->getValue('data');
  $this->configuration['returnToken'] = $form_state
    ->getValue('returnToken');
}