-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
61 lines (47 loc) · 2.8 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
declare(strict_types=1); // Declaring strict type
// Autoload function
spl_autoload_register(function($class){
require __DIR__ ."/src/$class.php";
});
set_error_handler("ErrorHandler::handleError"); //calling error handle to display error in JSON format
set_exception_handler("ErrorHandler::handleException"); // Class will loaded automatically
header("Content-type: application/json; charset=UTF-8"); // Setting Header type to JSON format
$parts = explode("/", $_SERVER['REQUEST_URI']); // Getting URL
$connection = new connection("localhost", "u498926327_tripbuilder","u498926327_pmtripbuilder","]/Vstmy=T6"); // Calling Connection class to connect with Database
// Getting Second part of url since the first part is Application name
if($parts[1] == "trips")
{
$id = $parts[2] ?? null;
$flightGateway = new flightGateway($connection); //Calling flightGatway with connection variable
$flightcontroller = new flightsController($flightGateway); // Calling flightController class with gatway variable
$flightcontroller->processRequest($_SERVER['REQUEST_METHOD'], $id); //sending Method with id in proceess Request function
}
if($parts[1] == "onewaytrip")
{
$oneWayGateway = new oneWayGateway($connection); //Calling flightGatway with connection variable
$oneWaycontroller = new oneWayController($oneWayGateway); // Calling flightController class with gatway variable
$oneWaycontroller->processRequest($_SERVER['REQUEST_METHOD']); //sending Method with id in proceess Request function
}
if($parts[1] == "roundtrip")
{
$id = $parts[2] ?? null;
$roundTripGateway = new roundTripGateway($connection); //Calling flightGatway with connection variable
$roundTripcontroller = new roundTripController($roundTripGateway); // Calling flightController class with gatway variable
$roundTripcontroller->processRequest($_SERVER['REQUEST_METHOD'], $id); //sending Method with id in proceess Request function
}
if($parts[1] == "airlines")
{
$id = $parts[3] ?? null;
$airlineGateway = new airlineGateway($connection); //Calling Airline Gateway with connection variable
$airlinescontroller = new airlinesController($airlineGateway); // Calling AirlineController class with gatway variable
$airlinescontroller->processRequest($_SERVER['REQUEST_METHOD'], $id); //sending Method with id in proceess Request function
}
if($parts[1] == "airports")
{
$id = $parts[2] ?? null;
$airportGateway = new airportGateway($connection); //Calling Airport Gateway with connection variable
$airportcontroller = new airportController($airportGateway); // Calling Airport class with gatway variable
$airportcontroller->processRequest($_SERVER['REQUEST_METHOD'], $id); //sending Method with id in proceess Request function
}
?>