Select Git revision
bootstrap-api.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.
bootstrap-api.php 1.22 KiB
<?php
/**
* @deprecated Since Stud.IP 5.0. Will be removed in Stud.IP 6.0.
*/
namespace {
StudipAutoloader::addAutoloadPath($GLOBALS['STUDIP_BASE_PATH'] . '/vendor/oauth-php/library');
// Set base url for URLHelper class
URLHelper::setBaseUrl($GLOBALS['CANONICAL_RELATIVE_PATH_STUDIP']);
}
namespace RESTAPI {
use Studip, OAuthStore;
// Define api version
const VERSION = '2';
$router = Router::getInstance();
// Register JSON content renderer
$router->registerRenderer(new Renderer\JSONRenderer, true);
// If in development mode, register debug content renderer
if (defined('Studip\\ENV') && Studip\ENV === 'development') {
$router->registerRenderer(new Renderer\DebugRenderer);
}
OAuthStore::instance('PDO', [
'dsn' => 'mysql:host=' . $GLOBALS['DB_STUDIP_HOST']
. ';dbname=' . $GLOBALS['DB_STUDIP_DATABASE'],
'username' => $GLOBALS['DB_STUDIP_USER'],
'password' => $GLOBALS['DB_STUDIP_PASSWORD']
]);
// Register default consumers
Consumer\Base::addType('http', 'RESTAPI\\Consumer\\HTTP');
Consumer\Base::addType('studip', 'RESTAPI\\Consumer\\Studip');
Consumer\Base::addType('oauth', 'RESTAPI\\Consumer\\OAuth');
}