PSR2 compliance for PHPCI/Controller - Issue #18
This commit is contained in:
parent
65f93555be
commit
e4a6e224c4
7 changed files with 658 additions and 680 deletions
|
|
@ -8,9 +8,10 @@
|
|||
*/
|
||||
|
||||
namespace PHPCI\Controller;
|
||||
use b8,
|
||||
b8\Store,
|
||||
PHPCI\Model\Build;
|
||||
|
||||
use b8;
|
||||
use b8\Store;
|
||||
use PHPCI\Model\Build;
|
||||
|
||||
/**
|
||||
* Github Controller - Processes webhook pings from Github.
|
||||
|
|
@ -20,44 +21,38 @@ use b8,
|
|||
*/
|
||||
class GithubController extends b8\Controller
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
$this->_buildStore = Store\Factory::getStore('Build');
|
||||
}
|
||||
public function init()
|
||||
{
|
||||
$this->_buildStore = Store\Factory::getStore('Build');
|
||||
}
|
||||
|
||||
public function webhook($project)
|
||||
{
|
||||
$payload = json_decode($this->getParam('payload'), true);
|
||||
public function webhook($project)
|
||||
{
|
||||
$payload = json_decode($this->getParam('payload'), true);
|
||||
|
||||
try
|
||||
{
|
||||
$build = new Build();
|
||||
$build->setProjectId($project);
|
||||
$build->setCommitId($payload['after']);
|
||||
$build->setStatus(0);
|
||||
$build->setLog('');
|
||||
$build->setCreated(new \DateTime());
|
||||
$build->setBranch(str_replace('refs/heads/', '', $payload['ref']));
|
||||
}
|
||||
catch(\Exception $ex)
|
||||
{
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
header('Ex: ' . $ex->getMessage());
|
||||
die('FAIL');
|
||||
}
|
||||
try {
|
||||
$build = new Build();
|
||||
$build->setProjectId($project);
|
||||
$build->setCommitId($payload['after']);
|
||||
$build->setStatus(0);
|
||||
$build->setLog('');
|
||||
$build->setCreated(new \DateTime());
|
||||
$build->setBranch(str_replace('refs/heads/', '', $payload['ref']));
|
||||
} catch (\Exception $ex) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
header('Ex: ' . $ex->getMessage());
|
||||
die('FAIL');
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$build = $this->_buildStore->save($build);
|
||||
$build->sendStatusPostback();
|
||||
}
|
||||
catch(\Exception $ex)
|
||||
{
|
||||
header('HTTP/1.1 500 Internal Server Error');
|
||||
header('Ex: ' . $ex->getMessage());
|
||||
die('FAIL');
|
||||
}
|
||||
|
||||
die('OK');
|
||||
}
|
||||
}
|
||||
try {
|
||||
$build = $this->_buildStore->save($build);
|
||||
$build->sendStatusPostback();
|
||||
} catch (\Exception $ex) {
|
||||
header('HTTP/1.1 500 Internal Server Error');
|
||||
header('Ex: ' . $ex->getMessage());
|
||||
die('FAIL');
|
||||
}
|
||||
|
||||
die('OK');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue