public function IconBundleOverviewForm::submitForm in Icon API 8
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
- src/
Form/ IconBundleOverviewForm.php, line 129
Class
- IconBundleOverviewForm
- Configure file system settings for this site.
Namespace
Drupal\icon\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$view_path_alias = $form_state
->getValue('icon_api_view_path_alias');
if ($form['global']['icon_api_view_path_alias']['#default_value'] !== $view_path_alias) {
\Drupal::configFactory()
->getEditable('icon.settings')
->set('icon_api_view_path_alias', $view_path_alias)
->save();
if (!empty($view_path_alias)) {
drupal_set_message(t('The view path alias, "%url", has been created for users with the %permission permission.', array(
'%permission' => 'view icon',
'%url' => base_path() . $view_path_alias,
)));
}
else {
drupal_set_message(t('The view path alias is disabled. Icons are now only viewable in the administrative area.'));
}
menu_rebuild();
}
if ($form_state
->getValue('icon_api_apache_suppress_warning')) {
\Drupal::configFactory()
->getEditable('icon.settings')
->set('icon_api_apache_suppress_warning', $form_state['values']['icon_api_apache_suppress_warning'])
->save();
// Remove message just set by building the form again.
unset($_SESSION['messages']['warning']);
}
$bundles = icon_bundles();
$saved_bundles = $form_state
->getValue('bundles');
foreach ($bundles as $name => $bundle) {
if (!isset($saved_bundles[$name]['status'])) {
continue;
}
$status = $saved_bundles[$name]['status'];
if ($status !== $bundle['status']) {
if ($status) {
icon_bundle_enable($bundle);
}
else {
icon_bundle_disable($bundle);
}
}
}
parent::submitForm($form, $form_state);
}