-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathstart.php
79 lines (64 loc) · 2.31 KB
/
start.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
use Layla\DBManager;
use Layla\API;
// --------------------------------------------------------------
// Load helpers
// --------------------------------------------------------------
require __DIR__.DS.'helpers'.EXT;
// --------------------------------------------------------------
// Load bundles
// --------------------------------------------------------------
//Bundle::start('thirdparty_dbmanager');
Bundle::start('thirdparty_bootsparks');
// --------------------------------------------------------------
// Load namespaces
// --------------------------------------------------------------
Autoloader::namespaces(array(
'Domain' => __DIR__,
));
// --------------------------------------------------------------
// Filters
// --------------------------------------------------------------
Route::filter('authority', function($resource)
{
$action = Request::$route->parameters['0'];
if(Authority::cannot($action, $resource))
{
return Response::make('', 401);
}
});
Route::filter('auth', function()
{
if (Auth::guest()) return Redirect::make('', 401);
});
// --------------------------------------------------------------
// Setting system tables
// --------------------------------------------------------------
DBManager::$hidden = Config::get('domain::dbmanager.hidden');
$api_version = Config::get('layla.domain.api.version');
// --------------------------------------------------------------
// Map the Base Controller
// --------------------------------------------------------------
Autoloader::map(array(
'Domain_Base_Controller' => __DIR__.DS.'controllers'.DS.'base'.EXT,
));
Route::filter('api_auth', function()
{
if( ! isset($_SERVER['PHP_AUTH_USER']) || ! isset($_SERVER['PHP_AUTH_PW']))
{
//return Response::json(array(), 401);
}
//Auth::attempt();
});
Bundle::start('thirdparty_bob');
// --------------------------------------------------------------
// Load the routes
// --------------------------------------------------------------
Route::group(array('before' => 'api_auth'), function() use ($api_version)
{
Route::api(Config::get('routes'), 'domain', Config::get('layla.domain.url_prefix'));
});
// --------------------------------------------------------------
// Set aliases
// --------------------------------------------------------------
Autoloader::alias('Domain\\Libraries\\Response', 'Response');