-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
76 lines (59 loc) · 1.66 KB
/
index.php
File metadata and controls
76 lines (59 loc) · 1.66 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
// 328/diner/index.php
// This is my CONTROLLER!
// Turn on error reporting
ini_set('display_errors', 1);
error_reporting(E_ALL);
// Require the necessary files
require_once ('vendor/autoload.php');
// Instantiate the F3 Base class (the router)
$f3 = Base::instance();
$con = new Controller($f3);
$dataLayer = new DataLayer();
/* TESTING
$myOrder = new Order('breakfast', 'pancakes', 'maple syrup');
$id = $dataLayer->saveOrder($myOrder);
echo "Order $id inserted successfully!";
$result = $dataLayer->getOrders();
var_dump($result);
*/
// Define a default route
// https://tostrander.greenriverdev.com/328/hello-fat-free/
$f3->route('GET /', function() {
$GLOBALS['con']->home();
});
$f3->route('GET /admin', function() {
$GLOBALS['con']->admin();
});
// Breakfast menu
$f3->route('GET /menus/breakfast', function() {
$GLOBALS['con']->breakfast();
});
// Lunch menu
$f3->route('GET /menus/lunch', function() {
//echo '<h1>My Breakfast Menu</h1>';
// Render a view page
$view = new Template();
echo $view->render('views/lunch-menu.html');
});
// Dinner menu
$f3->route('GET /menus/dinner', function() {
//echo '<h1>My Breakfast Menu</h1>';
// Render a view page
$view = new Template();
echo $view->render('views/dinner-menu.html');
});
// Order Summary
$f3->route('GET /summary', function($f3) {
$GLOBALS['con']->summary();
});
// Order Form Part I
$f3->route('GET|POST /order1', function() {
$GLOBALS['con']->order1();
});
// Order Form Part II
$f3->route('GET|POST /order2', function() {
$GLOBALS['con']->order2();
});
// Run Fat-Free
$f3->run();