You are here

public function NotificationsWidgetSettingsForm::storeEntityNotificationsSettings in Notifications widget 8

Store entity notification settings.

1 call to NotificationsWidgetSettingsForm::storeEntityNotificationsSettings()
NotificationsWidgetSettingsForm::submitForm in src/Form/NotificationsWidgetSettingsForm.php
Form submission handler.

File

src/Form/NotificationsWidgetSettingsForm.php, line 373

Class

NotificationsWidgetSettingsForm
Provides settings for Notification widget module.

Namespace

Drupal\notifications_widget\Form

Code

public function storeEntityNotificationsSettings($entity, $values) {
  foreach ($entity as $entityType => $entityTypeData) {
    $enableSettings = $entityType . '_enable';
    $enableCreate = $entityType . '_noti_create_message';
    $enableUpdate = $entityType . '_noti_update_message';
    $enableDelete = $entityType . '_noti_delete_message';
    $createLink = $entityType . '_redirect_create_link';
    $updateLink = $entityType . '_redirect_update_link';
    $deleteLink = $entityType . '_redirect_delete_link';
    $this
      ->config('notifications_widget.settings')
      ->set($enableSettings, implode(',', array_filter($values[$enableSettings])))
      ->set($enableCreate, $values[$enableCreate])
      ->set($enableUpdate, $values[$enableUpdate])
      ->set($enableDelete, $values[$enableDelete])
      ->set($createLink, $values[$createLink])
      ->set($updateLink, $values[$updateLink])
      ->set($deleteLink, $values[$deleteLink])
      ->save();
  }
}