Select Git revision
CourseTopic.class.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.
TracToGitlabPlugin.php 3.67 KiB
<?php
require_once __DIR__ . '/bootstrap.php';
final class TracToGitlabPlugin extends StudIPPlugin implements StandardPlugin, SystemPlugin
{
private $container = null;
public function __construct()
{
parent::__construct();
if (!is_object($GLOBALS['user']) || $GLOBALS['user']->id === 'nobody') {
return;
}
$this->buildNavigation();
}
public function getDIContainer()
{
if ($this->container === null) {
require_once __DIR__ . '/vendor/autoload.php';
$this->container = new Pimple\Container();
$this->container['trac'] = function () {
return new TracToGitlab\TracLookup(Config::get()->TRAC2GITLAB_TRAC_URL);
};
$this->container['gitlab'] = function () {
$builder = new Gitlab\HttpClient\Builder(
new GuzzleHttp\Client(),
new Http\Factory\Guzzle\RequestFactory(),
new Http\Factory\Guzzle\StreamFactory(),
new Http\Factory\Guzzle\UriFactory()
);
$client = new Gitlab\Client($builder);
$client->setUrl(Config::get()->TRAC2GITLAB_GITLAB_URL);
$client->authenticate(Config::get()->TRAC2GITLAB_GITLAB_TOKEN, Gitlab\Client::AUTH_HTTP_TOKEN);
return $client;
};
$this->container['gitlabProjectId'] = function () {
return Config::get()->TRAC2GITLAB_GITLAB_PROJECT_ID;
};
$this->container['gitlabPager'] = function ($c) {
return new Gitlab\ResultPager($c['gitlab']);
};
$this->container['parsedown'] = function () {
$parsedown = new Parsedown();
$parsedown->setSafeMode(true);
return $parsedown;
};
}
return $this->container;
}
public function getIconNavigation($course_id, $last_visit, $user_id)
{
return null;
}
public function getTabNavigation($course_id)
{
return [
'trac2gitlab' => new Navigation('trac2gitlab', PluginEngine::getURL($this, [], 'convert')),