-
Notifications
You must be signed in to change notification settings - Fork 3
/
_bundle.php
64 lines (56 loc) · 1.2 KB
/
_bundle.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
62
63
64
<?php
namespace Bundles\Jolt;
use Exception;
use e;
/**
* Jolt Bundle
* @author Nate Ferrero
*/
class Bundle {
public function route($path) {
$file = implode('/', $path);
$file = __DIR__ . '/library/script/' . $file;
e\disable_trace();
header("Content-Type: text/javascript");
if(file_exists($file))
readfile($file);
e\complete();
}
/**
* Handle Jolt redirects
* @author Nate Ferrero
*/
public function _on_redirect($url) {
if(!isset($_POST['@jolt']))
return;
header('Content-Type: text/json', true);
echo e\json_encode_safe(array('redirect' => $url, 'target' => $_POST['@jolt']['@target']));
exit;
}
/**
* Prevent Information Saving
*/
public function _on_informationSet($model, $key, $value) {
if($key === '@jolt')
return false;
}
/**
* Redirect to exception page if on jolt
* @author Nate Ferrero
*/
public function _on_exception($exception) {
if(!isset($_POST['@jolt']))
return;
/**
* Instead - let's show the error on the jolt page
*/
echo e\json_encode_safe(array('messages' => array(
array(
'type' => 'error',
'message' => $exception->getMessage()
)
)));
exit;
//e\redirect('/@exceptions/' . $exception->id);
}
}