Esempio 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;
 }
Esempio n. 2
0
 /**
  * Remove a specified job in the current crontab
  *
  * @param Job $job
  *
  * @return Crontab
  */
 public function removeJob(Job $job)
 {
     unset($this->jobs[$job->getHash()]);
     return $this;
 }
Esempio n. 3
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;
 }