Exemplo n.º 1
0
 public function deploy()
 {
     $this->ftpSettings = new Settings('ftp');
     $this->utils = new Utils();
     $this->remote = new Remote($this->ftpSettings);
     $localChanges = $this->getModifiedLocalFiles();
     $remoteChanges = $this->getModifiedRemoteFiles();
     $missingRemote = $this->getMissingRemoteFiles();
     // Merge the changes together
     foreach ($remoteChanges as $file => $change) {
         if (!isset($localChanges[$file])) {
             $localChanges[$file] = $change;
         }
     }
     foreach ($missingRemote as $file => $change) {
         if (!isset($localChanges[$file])) {
             $localChanges[$file] = $change;
         }
     }
     // Send the changes to the remote server:
     $status = $this->remote->sendChanges($localChanges);
     foreach ($status->messages as $message) {
         echo "Remote: {$message}\n";
     }
     $this->remote->cleanUp();
     // ...grab another remote snapshot
     $this->currentRemoteState = $this->remote->remoteScan();
     // if all went well (how do we know?), we're still here... so save state
     $this->remote->cleanUp();
     $this->remote->close();
     $this->saveState();
 }