/** * @param string $cronDayOfWeek * @return bool */ protected function isDayOfWeekPresentable($cronDayOfWeek) { /** * not presentable if cronDayOfWeek does not match any of the following values: * * (every day of week), * string containing comma (e.g. MON,WED,FRI - specified days of week) * {one or more alphanumeric sings}-{one or more a.n. signs} (e.g. FRI-SUN - from Friday to Sunday) * {one or more alphanumeric signs} (e.g. MON - only one day of week specified) */ if ($cronDayOfWeek !== '*' && strpos($cronDayOfWeek, ',') === false && !preg_match('#(\\w+)-(\\w+)#', $cronDayOfWeek) && !preg_match('#\\w+#', $cronDayOfWeek)) { return false; } /** * every x day of week not supported */ if (strpos($cronDayOfWeek, '/') !== false) { return false; } $dayArray = Noovias_Cron_Data_CronExpression_Settings_Day::getCronDayArray(); /** * in case that day of week is specified (many or just one) or the * from-to specification is set, * the day values should be contained in the day array, which is also used * by the template rendering cron expression drop-downs */ if (strpos($cronDayOfWeek, '-')) { preg_match('#(\\w+)-(\\w+)#', $cronDayOfWeek, $pockets); if (!in_array($pockets[1], $dayArray) || !in_array($pockets[2], $dayArray)) { return false; } } if (strpos($cronDayOfWeek, ',') !== false) { $cronDayArray = explode(',', $cronDayOfWeek); foreach ($cronDayArray as $item) { if (!in_array($item, $dayArray)) { return false; } } } if (preg_match('#\\w+#', $cronDayOfWeek, $pockets)) { if (!in_array($pockets[0], $dayArray)) { return false; } } return true; }
/** * @return array */ public function getCronDayArray() { return Noovias_Cron_Data_CronExpression_Settings_Day::getCronDayArray(); }