Exemplo n.º 1
0
 /**
  * @return void
  */
 private function runJobs(array $jobs)
 {
     foreach ($jobs as $job) {
         if (is_string($job) && preg_match('#^(https?|local|remote):(.+)#', $job, $m)) {
             if ($m[1] === 'local') {
                 $out = @system($m[2], $code);
                 $err = $code !== 0;
             } elseif ($m[1] === 'remote') {
                 $out = $this->server->execute($m[2]);
                 $err = FALSE;
             } else {
                 $err = ($out = @file_get_contents($job)) === FALSE;
             }
             $this->logger->log("{$job}: {$out}");
             if ($err) {
                 throw new \RuntimeException("Error in job {$job}");
             }
         } elseif (is_callable($job)) {
             if ($job($this->server, $this->logger, $this) === FALSE) {
                 throw new \RuntimeException('Error in job');
             }
         } else {
             throw new \InvalidArgumentException("Invalid job {$job}.");
         }
     }
 }
 /**
  * @param array $list
  * @param bool $reverse
  * @return void
  */
 protected function doRename(array $list, $reverse = FALSE)
 {
     foreach ($list as $pair) {
         // Skip invalid pair
         if (!is_array($pair) && count($pair) != 2) {
             continue;
         }
         list($old, $new) = $pair;
         // 1# rename to new file
         $this->server->renameFile($old, $new);
         $this->log(sprintf('rename from [%s] to [%s]', $old, $new));
         if (!$reverse) {
             // 2# store to batch
             $this->batch[self::MODE_RENAME][] = [$new, $old];
         }
     }
 }