Select Git revision
Jan-Hendrik Willms authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
Plugin.php 1.69 KiB
<?php
namespace TracToGitlab;
use Config;
use Gitlab;
use GuzzleHttp;
use Http;
use Parsedown;
use Pimple;
abstract class Plugin extends \StudIPPlugin
{
private $container = null;
public function getDIContainer()
{
if ($this->container === null) {
require_once $this->getPluginPath() . '/vendor/autoload.php';
$this->container = new Pimple\Container();
$this->container['trac'] = function () {
return new 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;
}
}