public function SettingsController::disablePopup in Popup Maker - All popup types 8
To disable the popup.
1 call to SettingsController::disablePopup()
- SettingsController::updateStatus in src/
Controller/ SettingsController.php - To update the status of popup.
File
- src/
Controller/ SettingsController.php, line 295
Class
- SettingsController
- Settings Controller to the popup maker module.
Namespace
Drupal\popup_maker\ControllerCode
public function disablePopup() {
if (!isset($_POST['id'])) {
$this->messenger
->addError('Parameter "id" is required to disable a popup');
return FALSE;
}
$id = abs(intval($_POST['id']));
if ($id != $_POST['id']) {
$this->messenger
->addError('Parameter "id" must be non negative integer');
return FALSE;
}
$config = $this->configFactory
->getEditable('popup_maker.settings');
$popupSettings = $config
->get('popupSettings');
if (empty($popupSettings)) {
$popupSettings = [];
}
if (!isset($popupSettings[$_POST['id']])) {
$popupSettings[$_POST['id']] = [];
}
$popupSettings[$_POST['id']]['enabled'] = 0;
$config
->set('popupSettings', $popupSettings)
->save();
$this->messenger
->addStatus('Popup Disabled successfully');
}