| @@ 85-107 (lines=23) @@ | ||
| 82 | * @throws \RuntimeException |
|
| 83 | * @return string |
|
| 84 | */ |
|
| 85 | public function get($src, $dest = null) |
|
| 86 | { |
|
| 87 | $realDest = $dest; |
|
| 88 | ||
| 89 | if (null == $dest) { |
|
| 90 | $realDest = tempnam(sys_get_temp_dir(), basename($src)); |
|
| 91 | } |
|
| 92 | ||
| 93 | $commandline = sprintf("rsync %s@%s:%s \"%s\"", $this->getUser(), $this->getHost(), $src, $realDest); |
|
| 94 | ||
| 95 | $this->dispatcher->dispatch(TransporterEvents::TRANSPORTER_GET, new TransporterEvent($this, array('src' => $src, 'dest' => $dest))); |
|
| 96 | ||
| 97 | if ($this->cli->execute($commandline)) { |
|
| 98 | throw new \RuntimeException($this->cli->getErrorOutput()); |
|
| 99 | } |
|
| 100 | ||
| 101 | if (null == $dest) { |
|
| 102 | $content = file_get_contents($realDest); |
|
| 103 | unlink($realDest); |
|
| 104 | ||
| 105 | return $content; |
|
| 106 | } |
|
| 107 | } |
|
| 108 | ||
| 109 | /** |
|
| 110 | * Upload a file or directory to remote server |
|
| @@ 84-106 (lines=23) @@ | ||
| 81 | * @throws \RuntimeException |
|
| 82 | * @return string |
|
| 83 | */ |
|
| 84 | public function get($src, $dest = null) |
|
| 85 | { |
|
| 86 | $realDest = $dest; |
|
| 87 | ||
| 88 | if (null == $dest) { |
|
| 89 | $realDest = tempnam(sys_get_temp_dir(), basename($src)); |
|
| 90 | } |
|
| 91 | ||
| 92 | $commandline = sprintf("scp %s@%s:%s \"%s\"", $this->getUser(), $this->getHost(), $src, $realDest); |
|
| 93 | ||
| 94 | $this->dispatcher->dispatch(TransporterEvents::TRANSPORTER_GET, new TransporterEvent($this, array('src' => $src, 'dest' => $dest))); |
|
| 95 | ||
| 96 | if ($this->cli->execute($commandline)) { |
|
| 97 | throw new \RuntimeException($this->cli->getErrorOutput()); |
|
| 98 | } |
|
| 99 | ||
| 100 | if (null == $dest) { |
|
| 101 | $content = file_get_contents($realDest); |
|
| 102 | unlink($realDest); |
|
| 103 | ||
| 104 | return $content; |
|
| 105 | } |
|
| 106 | } |
|
| 107 | ||
| 108 | /** |
|
| 109 | * Upload a file or directory to remote server |
|