expiredTemplate = $expiredTemplate; return $this; } public function setExpiresOnTemplate($expiresOnTemplate) { $this->expiresOnTemplate = $expiresOnTemplate; return $this; } protected function _doNothing() { exit; } public function _doDaily() { $this->notify(); $this->disableExpired(); return $this; } private function notify() { $dayMarks = App_Settings_Obj::get('licenseExpirationNotificationDays'); $dayMarks = preg_split('/[,\ ]+/', $dayMarks); $dayMarks = array_filter($dayMarks, function ($value) { return $value !== ''; }); if (empty($dayMarks)) { return; } $dayMarks = array_unique($dayMarks); sort($dayMarks); $expiredOnMap = []; foreach ($dayMarks as $dayMark) { $day = date('Y-m-d', strtotime('+' . $dayMark . ' days')); $expiredOnMap[$day] = (int) $dayMark; } $this->_getDataObj()->setFilter('expiredOn', array_keys($expiredOnMap)); foreach ($this->_getDataObj()->getListStatement() as $license) { $dayMark = $expiredOnMap[$license['expiredOn']]; $template = $dayMark == 0 ? $this->expiredTemplate : $this->expiresOnTemplate; $this->sendExpiredEmail($license, $template); } } abstract public function sendExpiredEmail(array $license, $template); private function disableExpired() { $this->_getDataObj()->disableExpired(App_Settings_Obj::get('licenseGracePeriod')); } }