Skip to content
Snippets Groups Projects
Select Git revision
  • b920ece0b531d05fc0ae3674011b18e5f0bc1c6d
  • main default protected
  • 5.5 protected
  • atlantis
  • 5.3 protected
  • 5.0 protected
  • issue-23
  • issue8-seat-logging-and-export
  • ticket-216
  • tickets-215-216-241-242
10 results

ChildrenOfTreeNode.php

Blame
  • 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);
        }
    }