Refactored Controller.
This commit is contained in:
parent
dd9f43b7dd
commit
d1c37fc293
4 changed files with 104 additions and 136 deletions
|
|
@ -11,10 +11,12 @@ use PHPCensor\Model\Project;
|
|||
use PHPCensor\Service\BuildService;
|
||||
use PHPCensor\Store\BuildStore;
|
||||
use PHPCensor\Store\ProjectStore;
|
||||
use b8\Controller;
|
||||
use PHPCensor\Controller;
|
||||
use PHPCensor\Config;
|
||||
use b8\Exception\HttpException\NotFoundException;
|
||||
use PHPCensor\Store\Factory;
|
||||
use b8\Http\Request;
|
||||
use b8\Http\Response;
|
||||
|
||||
/**
|
||||
* Webhook Controller - Processes webhook pings from BitBucket, Github, Gitlab, Gogs, etc.
|
||||
|
|
@ -42,6 +44,18 @@ class WebhookController extends Controller
|
|||
*/
|
||||
protected $buildService;
|
||||
|
||||
/**
|
||||
* @param Config $config
|
||||
* @param Request $request
|
||||
* @param Response $response
|
||||
*/
|
||||
public function __construct(Config $config, Request $request, Response $response)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->request = $request;
|
||||
$this->response = $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise the controller, set up stores and services.
|
||||
*/
|
||||
|
|
@ -63,7 +77,7 @@ class WebhookController extends Controller
|
|||
{
|
||||
$response = new b8\Http\Response\JsonResponse();
|
||||
try {
|
||||
$data = parent::handleAction($action, $actionParams);
|
||||
$data = call_user_func_array([$this, $action], $actionParams);
|
||||
if (isset($data['responseCode'])) {
|
||||
$response->setResponseCode($data['responseCode']);
|
||||
unset($data['responseCode']);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue