You are here

public function LtiToolProviderAttributesSettingsForm::submitForm in LTI Tool Provider 8

Same name and namespace in other branches
  1. 2.x modules/lti_tool_provider_attributes/src/Form/LtiToolProviderAttributesSettingsForm.php \Drupal\lti_tool_provider_attributes\Form\LtiToolProviderAttributesSettingsForm::submitForm()

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides ConfigFormBase::submitForm

File

modules/lti_tool_provider_attributes/src/Form/LtiToolProviderAttributesSettingsForm.php, line 75

Class

LtiToolProviderAttributesSettingsForm

Namespace

Drupal\lti_tool_provider_attributes\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $settings = $this
    ->config('lti_tool_provider_attributes.settings');
  $lti_launch = $this
    ->config('lti_tool_provider.settings')
    ->get('lti_launch');
  $mapped_attributes = [];
  foreach ($form_state
    ->getValue('mapped_attributes') as $key => $value) {
    if (in_array($value['lti_attribute'], $lti_launch)) {
      $mapped_attributes[$key] = $value['lti_attribute'];
    }
  }
  $settings
    ->set('mapped_attributes', $mapped_attributes)
    ->save();
}