aboutsummaryrefslogtreecommitdiff
path: root/public/dispatch.php
blob: d2ebdaff009f63a94a4e1f145dbd79bd695bdff1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
use Slim\App;
use Slim\Factory\AppFactory;

/*
 * index.php - <short-description>
 *
 * Copyright (C) 2006 - Marcus Lunzenauer <mlunzena@uos.de>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 */


require '../lib/bootstrap.php';

// prepare environment
URLHelper::setBaseUrl($GLOBALS['ABSOLUTE_URI_STUDIP']);

// Build PHP_DI Container
$container = app();

// Instantiate the app
AppFactory::setContainer($container);
$app = AppFactory::create();
$container->set(App::class, $app);
$app->setBasePath($GLOBALS['CANONICAL_RELATIVE_PATH_STUDIP'] . 'dispatch.php');

$studip_dispatcher = app(\Trails\Dispatcher::class);
$route_callable = $studip_dispatcher->getRouteCallable(Request::pathInfo());
$app->any(Request::pathInfo(), $route_callable);

// Add legacy director so links shall not break
$app->add(Studip\Middleware\LegacyRedirectorMiddleware::class);

NotificationCenter::postNotification('SLIM_BEFORE_RUN', $app);
$app->run();
NotificationCenter::postNotification('SLIM_AFTER_RUN', $app);