1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Define the project root and load up erdiko's core bootrap |
4
|
|
|
* You shouldn't have to change anything here unless you are |
5
|
|
|
* hacking together something unique |
6
|
|
|
*/ |
7
|
|
|
define('ERDIKO_ROOT', dirname(__DIR__)); |
8
|
|
|
define('ERDIKO_VENDOR', ERDIKO_ROOT.'/vendor'); |
9
|
|
|
define('ERDIKO_SRC', ERDIKO_VENDOR.'/erdiko/core/src'); |
10
|
|
|
require_once ERDIKO_SRC.'/bootstrap.php'; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Appstrap |
14
|
|
|
* Here you can modify safely based on your needs. |
15
|
|
|
* Add any application defined bootstrap items here |
16
|
|
|
*/ |
17
|
|
|
$debug = getenv("ERDIKO_DEBUG"); |
18
|
|
|
ini_set('display_errors', $debug); |
19
|
|
|
|
20
|
|
|
// To turn on Session (uncomment line below) |
21
|
|
|
// require_once ERDIKO.'/core/session.php'; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Hooks |
25
|
|
|
*/ |
26
|
|
|
\erdiko\core\ToroHook::add("404", function ($vars = array()) { |
27
|
|
|
// Toro::serve Legacy |
28
|
|
|
$vars['debug'] = \erdiko\core\ErrorHandler::isDebug(); |
29
|
|
|
if (empty($vars['message'])) { |
30
|
|
|
$vars['message'] = "Sorry, we cannot find that page."; |
31
|
|
|
} |
32
|
|
|
if (empty($vars['error'])) { |
33
|
|
|
$vars['error'] = $vars['message']; |
34
|
|
|
} |
35
|
|
|
if (!isset($vars['path_info'])) { |
36
|
|
|
$vars['path_info'] = ""; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
Erdiko::log(\Psr\Log\LogLevel::ERROR, "404 {$vars['path_info']} {$vars['error']}"); |
40
|
|
|
$vars['code'] = 404; |
41
|
|
|
|
42
|
|
|
$theme = new \erdiko\core\Theme( 'bootstrap' ); |
43
|
|
|
$theme->addCss( 'font-awesome', |
44
|
|
|
'//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css' ); |
45
|
|
|
$theme->addCss( 'font-awesome-animation', |
46
|
|
|
'/themes/bootstrap/css/font-awesome-animation.css' ); |
47
|
|
|
|
48
|
|
|
$response = new \erdiko\core\Response( $theme ); |
49
|
|
|
$response->setContent( \Erdiko::getView('error', $vars) ); |
|
|
|
|
50
|
|
|
$response->send(); |
51
|
|
|
}); |
52
|
|
|
|
53
|
|
View Code Duplication |
\erdiko\core\ToroHook::add("500", function ($vars = array()) { |
54
|
|
|
// Toro::serve Legacy |
55
|
|
|
$vars['debug'] = \erdiko\core\ErrorHandler::isDebug(); |
56
|
|
|
$vars['code'] = 500; |
57
|
|
|
$vars['message'] = "Sorry, something went wrong."; |
58
|
|
|
Erdiko::log(\Psr\Log\LogLevel::ERROR, "{$vars['code']}: {$vars['path_info']} {$vars['error']}"); |
59
|
|
|
|
60
|
|
|
$theme = new \erdiko\core\Theme( 'bootstrap' ); |
61
|
|
|
$theme->addCss( 'font-awesome', |
62
|
|
|
'//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css' ); |
63
|
|
|
$theme->addCss( 'font-awesome-animation', |
64
|
|
|
'/themes/bootstrap/css/font-awesome-animation.css' ); |
65
|
|
|
|
66
|
|
|
$response = new \erdiko\core\Response( $theme ); |
67
|
|
|
$response->setContent( \Erdiko::getView('error', $vars) ); |
|
|
|
|
68
|
|
|
$response->send(); |
69
|
|
|
}); |
70
|
|
|
|
71
|
|
|
// Error management & beautify output. |
72
|
|
View Code Duplication |
\erdiko\core\ToroHook::add("general_error", function ($vars = array()) { |
73
|
|
|
$vars['debug'] = \erdiko\core\ErrorHandler::isDebug(); |
74
|
|
|
if(!isset($vars['path_info'])){ |
75
|
|
|
$vars['path_info'] = $_SERVER['REQUEST_URI']; |
76
|
|
|
} |
77
|
|
|
Erdiko::log(\Psr\Log\LogLevel::ERROR, "{$vars['code']}: {$vars['path_info']} {$vars['error']}"); |
78
|
|
|
|
79
|
|
|
$theme = new \erdiko\core\Theme('bootstrap'); |
80
|
|
|
$theme->addCss('font-awesome', |
81
|
|
|
'//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css'); |
82
|
|
|
$theme->addCss('font-awesome-animation', |
83
|
|
|
'/themes/bootstrap/css/font-awesome-animation.css'); |
84
|
|
|
|
85
|
|
|
$response = new \erdiko\core\Response($theme); |
86
|
|
|
$response->setContent(\Erdiko::getView('error', $vars)); |
|
|
|
|
87
|
|
|
$response->send(); |
88
|
|
|
}); |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: