Ejemplo n.º 1
0
 /**
  * remove a job
  *
  * @param string $job
  * @return $this
  */
 public function removeJob($job = '')
 {
     if ($job instanceof TaskReposity) {
         $job = $job->buildCommandWithExpression();
     }
     $refrector = new CronEntry();
     $job = $refrector->parse($job);
     $this->getManager()->removeJob($job);
     return $this;
 }
Ejemplo n.º 2
0
 /**
  * Returns an array of Cron Jobs based on the contents of a file.
  *
  * @param string $input
  *
  * @return Job[]
  */
 protected function parseString($input)
 {
     $jobs = array();
     $lines = array_filter(explode(PHP_EOL, $input), function ($line) {
         return '' != trim($line);
     });
     foreach ($lines as $line) {
         $trimmed = trim($line);
         if (strstr($line, 'PATH=') || strstr($line, 'MAILTO=')) {
             continue;
         }
         // if line is not a comment, convert it to a cron
         if (0 !== \strpos($trimmed, '#')) {
             $jobs[] = Job::parse($line);
         }
     }
     return $jobs;
 }