public function SettingsController::enablePopup in Popup Maker - All popup types 8
To enable the popup.
1 call to SettingsController::enablePopup()
- SettingsController::updateStatus in src/
Controller/ SettingsController.php - To update the status of popup.
File
- src/
Controller/ SettingsController.php, line 330
Class
- SettingsController
- Settings Controller to the popup maker module.
Namespace
Drupal\popup_maker\ControllerCode
public function enablePopup() {
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'] = 1;
$config
->set('popupSettings', $popupSettings)
->save();
$this->messenger
->addStatus('Popup Enabled successfully');
}