public function HideNotificationController::hide in OptimizeDB 8
Page hide notification.
Return value
string Result hide notification.
1 string reference to 'HideNotificationController::hide'
File
- src/
Controller/ HideNotificationController.php, line 70
Class
- HideNotificationController
- Page hide notification.
Namespace
Drupal\optimizedb\ControllerCode
public function hide() {
$time = $this->time
->getRequestTime();
$config = $this->configFactory
->getEditable('optimizedb.settings');
$notify_optimize = $config
->get('notify_optimize');
// There is a need to disable the notification?
if ($notify_optimize) {
$config
->set('notify_optimize', FALSE)
->set('last_optimization', $time)
->save();
$optimization_period = (int) $config
->get('optimization_period');
$time_next_optimization = strtotime('+ ' . $optimization_period . ' day', $time);
$output = $this
->t('The following message on the need to perform optimization, you get - @date.', [
'@date' => $this->dateFormatter
->format($time_next_optimization),
]);
}
else {
$output = $this
->t('Alerts are not available.');
}
return [
'#type' => 'markup',
'#markup' => $output,
];
}