Skip to content

Commit

Permalink
Merge pull request #66 from code2prog/2.0
Browse files Browse the repository at this point in the history
The installGitRepositoryOnSite method should return the Site object, …
  • Loading branch information
themsaid authored May 14, 2020
2 parents 30fa738 + 2b5e59b commit e00d41b
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/Actions/ManagesSites.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,20 @@ public function updateSiteEnvironmentFile($serverId, $siteId, $content)
* @param integer $siteId
* @param array $data
* @param boolean $wait
* @return void
* @return Site
*/
public function installGitRepositoryOnSite($serverId, $siteId, array $data, $wait = true)
{
$this->post("servers/$serverId/sites/$siteId/git", $data);
$site = $this->post("servers/$serverId/sites/$siteId/git", $data);

if ($wait) {
$this->retry($this->getTimeout(), function () use ($serverId, $siteId) {
return $this->site($serverId, $siteId)->repositoryStatus === 'installed';
return $this->retry($this->getTimeout(), function () use ($serverId, $siteId) {
$site = $this->site($serverId, $siteId);
return $site->repositoryStatus === 'installed' ? $site : null;
});
}

return new Site($site + ['server_id' => $serverId], $this);
}

/**
Expand Down Expand Up @@ -259,13 +262,16 @@ public function disableQuickDeploy($serverId, $siteId)
*/
public function deploySite($serverId, $siteId, $wait = true)
{
$this->post("servers/$serverId/sites/$siteId/deployment/deploy");
$site = $this->post("servers/$serverId/sites/$siteId/deployment/deploy");

if ($wait) {
$this->retry($this->getTimeout(), function () use ($serverId, $siteId) {
return is_null($this->site($serverId, $siteId)->deploymentStatus);
return $this->retry($this->getTimeout(), function () use ($serverId, $siteId) {
$site = $this->site($serverId, $siteId);
return !is_null($site->deploymentStatus) ? $site : null;
});
}

return new Site($site + ['server_id' => $serverId], $this);
}

/**
Expand Down

0 comments on commit e00d41b

Please sign in to comment.