/**
  * {@inheritdoc}
  */
 public function submitConfigurationForm(array &$form, FormStateInterface $form_state)
 {
     $values = $form_state->getValues();
     // Since the form is nested into another, we can't simply use #parents for
     // doing this array restructuring magic. (At least not without creating an
     // unnecessary dependency on internal implementation.)
     $values += $values['http'];
     $values += $values['advanced'];
     $values += !empty($values['autocomplete']) ? $values['autocomplete'] : array();
     unset($values['http'], $values['advanced'], $values['autocomplete']);
     // Highlighting retrieved data only makes sense when we retrieve data.
     $values['highlight_data'] &= $values['retrieve_data'];
     // For password fields, there is no default value, they're empty by default.
     // Therefore we ignore empty submissions if the user didn't change either.
     if ($values['http_pass'] === '' && isset($this->configuration['http_user']) && $values['http_user'] === $this->configuration['http_user']) {
         $values['http_pass'] = $this->configuration['http_pass'];
     }
     foreach ($values as $key => $value) {
         $form_state->setValue($key, $value);
     }
     // The server description is a #type item element, which means it has a
     // value, do not save it.
     $form_state->unsetValue('server_description');
     parent::submitConfigurationForm($form, $form_state);
 }
示例#2
0
文件: Database.php 项目: jkyto/agolf
  /**
   * Implements the magic __wakeup() method.
   *
   * Reloads the database connection and logger.
   */
  public function __wakeup() {
    parent::__wakeup();

    if (isset($this->configuration['database'])) {
      list($key, $target) = explode(':', $this->configuration['database'], 2);
      $this->database = CoreDatabase::getConnection($target, $key);
    }
    $this->logger = \Drupal::service('logger.factory')->get('search_api_db');
  }
 /**
  * {@inheritdoc}
  */
 public function __construct(array $configuration, $plugin_id, array $plugin_definition, ModuleHandlerInterface $module_handler)
 {
     parent::__construct($configuration, $plugin_id, $plugin_definition);
     $this->moduleHandler = $module_handler;
 }