コード例 #1
0
 /**
  * @param string $cronMonth
  * @return bool
  */
 protected function isMonthPresentable($cronMonth)
 {
     /**
      * not presentable if cronMonth does not match any of the following values:
      * * (every month),
      * string containing comma (e.g. JAN,MAR,MAY - specified month)
      * {one or more alphanumeric signs}-{one or more a.n. signs} (e.g. MAR-MAY - from March to May)
      * {one or more alphanumeric signs} (e.g. AUG - only one month specified)
      */
     if ($cronMonth !== '*' && strpos($cronMonth, ',') === false && !preg_match('#(\\w+)-(\\w+)#', $cronMonth) && !preg_match('#\\w+#', $cronMonth)) {
         return false;
     }
     /**
      * expression like e.g. every 3 month not supported
      */
     if (strpos($cronMonth, '/') !== false) {
         return false;
     }
     $monthArray = Noovias_Cron_Data_CronExpression_Settings_Month::getCronMonthArray();
     /**
      * in case of from-to specification
      * the month values should be contained in the Array, which is also used by the template
      * rendering cron expression drop-downs
      */
     if (strpos($cronMonth, '-')) {
         preg_match('#(\\w+)-(\\w+)#', $cronMonth, $pockets);
         if (!in_array($pockets[1], $monthArray) || !in_array($pockets[2], $monthArray)) {
             return false;
         }
     }
     /**
      * if months are specified (string containing comma),
      * every month value should be contained in the month array
      */
     if (strpos($cronMonth, ',') !== false) {
         $cronMonthArray = explode(',', $cronMonth);
         foreach ($cronMonthArray as $item) {
             if (!in_array($item, $monthArray)) {
                 return false;
             }
         }
     }
     /**
      * in case when only one month is specified, it should be contained in
      * the month array
      */
     if (preg_match('#\\w+#', $cronMonth, $pockets)) {
         if (!in_array($pockets[0], $monthArray)) {
             return false;
         }
     }
     return true;
 }
コード例 #2
0
 /**
  * @return array
  */
 public function getCronMonthArray()
 {
     return Noovias_Cron_Data_CronExpression_Settings_Month::getCronMonthArray();
 }