function addHook($owner, $repo) {
$hook_conf = $this->app->getRequest()->getForm();
- $this->github->createRepoHook("$owner/$repo", $hook_conf, function($hook) use($owner, $repo) {
+ $this->github->createRepoHook("$owner/$repo", $hook_conf)->then(function($hook) use($owner, $repo) {
$call = new ListHooks($this->github, ["repo" => "$owner/$repo", "fresh" => true]);
- $call(function($hooks, $links) use($owner, $repo, $call) {
- $call->saveToCache([$hooks, $links]);
+ $this->github->queue($call)->then(function() use($owner, $repo) {
$this->redirectBack("$owner/$repo");
});
- })->send();
+ });
+ $this->github->drain();
}
function updateHook($owner, $repo) {
- $this->github->readRepo("$owner/$repo", function($repo) {
- $call = $this->github->listHooks($repo->full_name, function($hooks, $links) use($repo, &$call) {
- $repo->hooks = $hooks;
+ $this->github->readRepo("$owner/$repo")->then(function($result) {
+ list($repo) = $result;
+ $call = new ListHooks($this->github, ["repo" => $repo->full_name]);
+ $this->github->queue($call)->then(function($result) use($repo, $call) {
+ list($repo->hooks) = $result;
if (($hook = $this->github->checkRepoHook($repo))) {
$hook_conf = $this->app->getRequest()->getForm();
- $this->github->updateRepoHook($repo->full_name, $hook->id, $hook_conf, function($changed_hook) use($repo, $hook, $hooks, $links, &$call) {
+ $this->github->updateRepoHook($repo->full_name, $hook->id, $hook_conf)->then(function($hook_result) use($repo, $hook, $result, $call) {
+ list($changed_hook) = $hook_result;
foreach ($changed_hook as $key => $val) {
$hook->$key = $val;
}
- $call->saveToCache([$hooks, $links]);
+ $call->saveToCache($result);
$this->redirectBack($repo->full_name);
});
}
});
- })->send();
+ });
+ $this->github->drain();
}
function delHook($owner, $repo) {
- $this->github->readRepo("$owner/$repo", function($repo) {
- $call = $this->github->listHooks($repo->full_name, function($hooks) use($repo, &$call) {
- $repo->hooks = $hooks;
+ $this->github->readRepo("$owner/$repo")->then(function($result) {
+ list($repo) = $result;
+ $call = new ListHooks($this->github, ["repo" => $repo->full_name]);
+ $this->github->queue($call)->then(function($result) use($repo, $call) {
+ list($repo->hooks) = $result;
if (($hook = $this->github->checkRepoHook($repo))) {
- $this->github->deleteRepoHook($repo->full_name, $hook->id, function() use($repo, &$call) {
+ $this->github->deleteRepoHook($repo->full_name, $hook->id)->then(function() use($repo, $call) {
$call->dropFromCache();
$this->redirectBack($repo->full_name);
});
}
});
- })->send();
+ });
+ $this->github->drain();
}
function redirectBack($repo) {
use app\Github\API\Call;
use app\Github\Exception\RequestException;
use http\Client\Request;
+use http\Client\Response;
class CreateHook extends Call
{
- function enqueue(callable $callback) {
+ function request() {
$url = $this->url->mod("./repos/". $this->args["repo"] ."/hooks");
$request = new Request("POST", $url, [
"Authorization" => "token " . $this->api->getToken(),
]
]));
- $this->api->getClient()->enqueue($request, function($response) use($callback) {
- if ($response->getResponseCode() >= 400 || null === ($json = json_decode($response->getBody()))) {
- throw new RequestException($response);
- }
- $this->result = [$json];
- $callback($json);
- return true;
- });
+ return $request;
+ }
+
+ function response(Response $response) {
+ if ($response->getResponseCode() >= 400 || null === ($json = json_decode($response->getBody()))) {
+ throw new RequestException($response);
+ }
+ return [$json];
}
}
use app\Github\API\Call;
use app\Github\Exception\RequestException;
use http\Client\Request;
+use http\Client\Response;
class DeleteHook extends Call
{
- function enqueue(callable $callback) {
+ function request() {
$url = $this->url->mod(uri_template("./repos/{+repo}/hooks{/id}", $this->args));
$request = new Request("DELETE", $url, [
"Authorization" => "token " . $this->api->getToken(),
"Accept" => $this->config->api->accept,
]);
- $this->api->getClient()->enqueue($request, function($response) use($callback) {
- if ($response->getResponseCode() >= 400) {
- throw new RequestException($response);
- }
- $callback();
- return true;
- });
+ return $request;
+ }
+
+ function response(Response $response) {
+ if ($response->getResponseCode() >= 400) {
+ throw new RequestException($response);
+ }
}
}
namespace app\Github\API\Hooks;
-class UpdateHook extends \app\Github\API\Call
+use app\Github\API\Call;
+use app\Github\Exception\RequestException;
+use http\Client\Request;
+use http\Client\Response;
+
+class UpdateHook extends Call
{
- function enqueue(callable $callback) {
+ function request() {
$url = $this->url->mod(uri_template("./repos/{+repo}/hooks{/id}", $this->args));
- $request = new \http\Client\Request("PATCH", $url, [
+ $request = new Request("PATCH", $url, [
"Authorization" => "token ". $this->api->getToken(),
"Accept" => $this->config->api->accept,
"Content-Type" => "application/json",
];
$request->getBody()->append(json_encode(compact("events", "config")));
- $this->api->getClient()->enqueue($request, function($response) use($callback) {
- if ($response->getResponseCode() >= 400 || null === ($json = json_decode($response->getBody()))) {
- throw new \app\Github\Exception\RequestException($response);
- }
- $this->result = [$json];
- $callback($json);
- return true;
- });
+ return $request;
+ }
+
+ function response(Response $response) {
+ if ($response->getResponseCode() >= 400 || null === ($json = json_decode($response->getBody()))) {
+ throw new RequestException($response);
+ }
+ return [$json];
}
}
use app\Github\API\Call;
use app\Github\Exception\RequestException;
use http\Client\Request;
+use http\Client\Response;
class CreateRelease extends Call
{
- function enqueue(callable $callback) {
+ function request() {
$url = $this->url->mod("/repos/". $this->args["repo"] ."/releases");
$request = new Request("POST", $url, [
"Authorization" => "token ". $this->api->getToken(),
"tag_name" => $this->args["tag"],
"draft" => true,
]));
- $this->api->getClient()->enqueue($request, function($response) use($callback) {
- if ($response->getResponseCode() >= 400 || null === ($json = json_decode($response->getBody()))) {
- throw new RequestException($response);
- }
- $this->result = [$json];
- $callback($json);
- return true;
- });
+ return $request;
+ }
+
+ function response(Response $response) {
+ if ($response->getResponseCode() >= 400 || null === ($json = json_decode($response->getBody()))) {
+ throw new RequestException($response);
+ }
+ return [$json];
}
}
use app\Github\API\Call;
use app\Github\Exception\RequestException;
use http\Client\Request;
+use http\Client\Response;
use http\Message\Body;
class CreateReleaseAsset extends Call
{
- function enqueue(callable $callback) {
+ function request() {
$body = new Body(fopen($this->args["asset"], "rb"));
$request = new Request("POST", $this->args["url"], [
"Authorization" => "token ". $this->api->getToken(),
"Accept" => $this->config->api->accept,
"Content-Type" => $this->args["type"],
], $body);
- $this->api->getClient()->enqueue($request, function($response) use($callback) {
- if ($response->getResponseCode() >= 400 || null === ($json = json_decode($response->getBody()))) {
- throw new RequestException($response);
- }
- $this->result = [$json];
- $callback($json);
- return true;
- });
+ return $request;
+ }
+
+ function response(Response $response) {
+ if ($response->getResponseCode() >= 400 || null === ($json = json_decode($response->getBody()))) {
+ throw new RequestException($response);
+ }
+ return [$json];
}
}
use app\Github\API\Call;
use app\Github\Exception\RequestException;
use http\Client\Request;
+use http\Client\Response;
class PublishRelease extends Call
{
- function enqueue(callable $callback) {
+ function request() {
$url = $this->url->mod(uri_template("./repos/{+repo}/releases{/id}", $this->args));
$request = new Request("PATCH", $url, [
"Authorization" => "token ". $this->api->getToken(),
"draft" => false,
"tag_name" => $this->args["tag"],
]));
- $this->api->getClient()->enqueue($request, function($response) use($callback) {
- if ($response->getResponseCode() >= 400 || null === ($json = json_decode($response->getBody()))) {
- throw new RequestException($response);
- }
- $this->result = [$json];
- $callback($json);
- return true;
- });
+ return $request;
+ }
+
+ function response(Response $response) {
+ if ($response->getResponseCode() >= 400 || null === ($json = json_decode($response->getBody()))) {
+ throw new RequestException($response);
+ }
+ return [$json];
}
}
\ No newline at end of file
<?php if (!empty($v->release)) : ?>
<p><?= $this->md($v->release->body) ?></p>
<?php endif; ?>
- <ul class="list-inline">
- <li>
- <span class="octicon octicon-tag" title="Tag"></span>
- <span class="label label-default"><?= $this->e($v->tag->name) ?></span>
- </li>
+ <ul class="list-inline">
+ <li>
+ <span class="octicon octicon-tag" title="Tag"></span>
+ <span class="label label-default"><?= $this->e($v->tag->name) ?></span>
+ </li>
- <?php if (!empty($v->release)) : ?>
- <li>
- <span class="octicon octicon-git-branch" title="Branch"></span>
- <span class="label label-default"><?= $this->e($v->release->target_commitish) ?></span>
- </li>
- <li>
- <span class="octicon octicon-clock" title="Date"></span>
- <span class="label label-default">
- <time datetime="<?= $v->release->published_at ?>">
- <?= $this->utc($v->release->published_at)->format("Y-m-d H:i T") ?>
- </time>
- </span>
- <?php endif; ?>
- </ul>
+ <?php if (!empty($v->release)) : ?>
+ <li>
+ <span class="octicon octicon-git-branch" title="Branch"></span>
+ <span class="label label-default"><?= $this->e($v->release->target_commitish) ?></span>
+ </li>
+ <li>
+ <span class="octicon octicon-clock" title="Date"></span>
+ <span class="label label-default">
+ <time datetime="<?= $v->release->published_at ?>">
+ <?= $this->utc($v->release->published_at)->format("Y-m-d H:i T") ?>
+ </time>
+ </span>
+ <?php endif; ?>
+ </ul>
</div>
<div class="col-sm-4">
- <ul class="list-inline pull-right">
<?php if (!empty($v->release->assets)) : ?>
- <?php foreach ($v->release->assets as $asset) : ?>
- <?php if (fnmatch("*.ext.phar", $asset->name)) : ?>
- <li>
- <a class="btn btn-success" href="<?= $this->e($asset->browser_download_url) ?>">
- <span class="octicon octicon-package"></span>
- <?= $this->e($asset->name) ?>
- </a>
- </li>
- <?php endif; ?>
- <?php endforeach; ?>
+ <ul class="list-inline pull-right">
+ <?php foreach ($v->release->assets as $asset) : ?>
+ <?php if (fnmatch("*.ext.phar", $asset->name)) : ?>
+ <li>
+ <a class="btn btn-success" href="<?= $this->e($asset->browser_download_url) ?>">
+ <span class="octicon octicon-package"></span>
+ <?= $this->e($asset->name) ?>
+ </a>
+ </li>
+ <?php endif; ?>
+ <?php endforeach; ?>
+ </ul>
<?php else: ?>
- <form class="form-inline" method="post" action="<?= $baseUrl->mod("./github/repo/". $repo->full_name ."/release") ?>">
+ <form class="form-inline pull-right" method="post" action="<?= $baseUrl->mod("./github/repo/". $repo->full_name ."/release") ?>">
<input type="hidden" name="tag" value="<?= $this->e($v->tag->name) ?>">
<div class="checkbox">
<label for="hook-zend">
</button>
</form>
<?php endif; ?>
- </ul>
+
</div>
</div>
</div>