Select Git revision
ChildrenOfTreeNode.php
Forked from
Stud.IP / Stud.IP
Source project has a limited visibility.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
hooks.php 1.65 KiB
<?php
use TracToGitlab\EventController;
use TracToGitlab\EventHandler;
use TracToGitlab\EventHandlers;
final class HooksController extends EventController
{
public function system_action()
{
if (!$this->verifySecret(Config::get()->getValue('TRAC2GITLAB_GITLAB_SYSTEMHOOK_SECRET'))) {
$this->halt('Thou shalt not pass.', 403);
}
if (!$this->verifyEvent()) {
$this->halt('This is not a valid gitlab event');
}
$this->processHooks($this->getKnownSystemhooks());
}
/**
* @return iterator|EventHandler[]
*/
private function getKnownSystemhooks(): iterator
{
yield app(EventHandlers\UserCreated::class);
}
public function web_action()
{
// if (!$this->verifySecret(Config::get()->getValue('TRAC2GITLAB_GITLAB_WEBHOOK_SECRET'))) {
// $this->halt('Thou shalt not pass.', 403);
// }
//
dd(app(EventHandlers\BranchDeleted::class));
$payload = $this->payload();
if (
!$this->verifyEvent()
|| !isset($payload['project']['id'])
|| $payload['project']['id'] != $this->gitlab_project_id
) {
$this->halt('This is not a valid gitlab event');
}
$this->processHooks($this->getKnownWebhooks());
}
/**
* @return iterator|EventHandler[]
*/
private function getKnownWebhooks(): iterator
{
yield app(EventHandlers\AllAutomaticJobsHaveSucceeded::class);
yield app(EventHandlers\BranchDeleted::class);
yield app(EventHandlers\BuildImageJobSucceeded::class);
yield app(EventHandlers\IssueCreated::class);
}
}