diff --git a/src/Form/SettingsForm.php b/src/Form/SettingsForm.php index 9aeadd0..449a9ff 100644 --- a/src/Form/SettingsForm.php +++ b/src/Form/SettingsForm.php @@ -77,16 +77,38 @@ class SettingsForm extends ConfigFormBase { * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { - $types = array_keys(array_filter($form_state->getValue(['filters', 'types']))); - $statuses = array_keys(array_filter($form_state->getValue(['filters', 'statuses']))); - $forbidden = array_keys(array_filter($form_state->getValue(['filters', 'refine', 'forbidden']))); - $allowed = array_keys(array_filter($form_state->getValue(['filters', 'refine', 'allowed']))); + + $types = []; + $filters_types = $form_state->getValue(['filters', 'types']); + if (isset($filters_types) && is_array($filters_types)) { + $types = array_keys(array_filter($form_state->getValue(['filters', 'types']))); + } + + $statuses = []; + $filters_statuses = $form_state->getValue(['filters', 'statuses']); + if (isset($filters_statuses) && is_array($filters_statuses)) { + $statuses = array_keys(array_filter($form_state->getValue(['filters', 'statuses']))); + } + + $forbidden = []; + $filters_refine_forbidden = $form_state->getValue(['filters', 'refine', 'forbidden']); + if (isset($filters_refine_forbidden) && is_array($filters_refine_forbidden)) { + $forbidden = array_keys(array_filter($form_state->getValue(['filters', 'refine', 'forbidden']))); + } + + $allowed = []; + $filters_refine_allowed = $form_state->getValue(['filters', 'refine', 'allowed']); + if (isset($filters_refine_allowed) && is_array($filters_refine_allowed)) { + $allowed = array_keys(array_filter($form_state->getValue(['filters', 'refine', 'allowed']))); + } + $this->config('cl_block.settings') ->set('types', $types) ->set('statuses', $statuses) ->set('forbidden', $forbidden) ->set('allowed', $allowed) ->save(); + // Refresh the list of blocks after saving settings. $manager = isset($this->blockManager) ? $this->blockManager : \Drupal::service('plugin.manager.block'); $manager->clearCachedDefinitions();