forked from podolaceklukas/assignment-gis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
36 lines (29 loc) · 1.28 KB
/
index.php
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
<?php
require_once __DIR__ . '/vendor/autoload.php';
use Database\PostgressDb;
use Repository\BarRepository;
use Core\Routing;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
$parametersJson = file_get_contents('config/parameters.json');
$parameters = json_decode($parametersJson, true);
$database = new PostgressDb($parameters['host'], $parameters['port'], $parameters['dbName'],
$parameters['userName'], $parameters['userPassword']);
$database->connect();
$wtfRepository = new BarRepository();
$request = Request::createFromGlobals();
$router = new Routing();
try {
$routeParameters = $router->matchRoute($request);
$objectString = 'Controller\\'.$routeParameters['controller'];
$object = new $objectString($database, $wtfRepository);
$responseData = $object->{$routeParameters['action']}($request);
}
catch (Symfony\Component\Routing\Exception\ResourceNotFoundException $exception) {
$response = new Response();
$response->prepare($request);
$response->setContent('Not Found');
$response->setStatusCode(Response::HTTP_NOT_FOUND);
$response->send();
}
$database->disconnect();