Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     // Frequently used configuration items.
     $check_settings = $this->config('security_review.checks');
     // Save that the module has been configured.
     SecurityReview::setConfigured(TRUE);
     // Save the new untrusted roles.
     $untrusted_roles = array_keys(array_filter($form_state->getValue('untrusted_roles')));
     SecurityReview::setUntrustedRoles($untrusted_roles);
     // Save the new logging setting.
     $logging = $form_state->getValue('logging') == 1;
     SecurityReview::setLogging($logging);
     // Skip selected checks.
     $skipped = array_keys(array_filter($form_state->getValue('skip')));
     foreach (Checklist::getChecks() as $check) {
         if (in_array($check->id(), $skipped)) {
             $check->skip();
         } else {
             $check->enable();
         }
     }
     // Save the check-specific settings.
     if (isset($form['advanced']['check_specific'])) {
         $checkSpecificValues = $form_state->getValue('check_specific');
         foreach ($checkSpecificValues as $checkIdentifier => $values) {
             // Get corresponding Check.
             $check = Checklist::getCheckByIdentifier($checkIdentifier);
             // Submit parameters.
             $checkForm =& $form['advanced']['check_specific'][$checkIdentifier]['form'];
             $checkFormValues = $checkSpecificValues[$checkIdentifier]['form'];
             // Submit.
             $check->settings()->submitForm($checkForm, $checkFormValues);
         }
     }
     // Commit the settings.
     $check_settings->save();
     // Finish submitting the form.
     parent::submitForm($form, $form_state);
 }
 /**
  * Tests the 'logging' setting.
  */
 public function testConfigLogging()
 {
     $this->assertTrue(SecurityReview::isLogging(), 'Logging enabled by default.');
     SecurityReview::setLogging(FALSE);
     $this->assertFalse(SecurityReview::isLogging(), 'Logging disabled.');
 }