Beispiel #1
0
 /**
  * Builds the backend-specific configuration form.
  *
  * @param \Drupal\search_api\ServerInterface $server
  *   The server that is being created or edited.
  */
 public function buildBackendConfigForm(array &$form, FormStateInterface $form_state, ServerInterface $server)
 {
     $form['backend_config'] = array('#type' => 'container', '#attributes' => array('id' => 'search-api-backend-config-form'), '#tree' => TRUE);
     if ($server->hasValidBackend()) {
         $backend = $server->getBackend();
         if ($backend_form = $backend->buildConfigurationForm(array(), $form_state)) {
             // If the backend plugin changed, notify the user.
             if (!empty($form_state->getValues()['backend'])) {
                 drupal_set_message($this->t('Please configure the used backend.'), 'warning');
             }
             // Modify the backend plugin configuration container element.
             $form['backend_config']['#type'] = 'details';
             $form['backend_config']['#title'] = $this->t('Configure %plugin backend', array('%plugin' => $backend->label()));
             $form['backend_config']['#description'] = $backend->getDescription();
             $form['backend_config']['#open'] = TRUE;
             // Attach the backend plugin configuration form.
             $form['backend_config'] += $backend_form;
         }
     } elseif (!$server->isNew()) {
         drupal_set_message($this->t('The backend plugin is missing or invalid.'), 'error');
     }
 }