Skip to content

Commit 0acb366

Browse files
committed
Updated Core
1 parent dc24620 commit 0acb366

File tree

3 files changed

+21
-112
lines changed

3 files changed

+21
-112
lines changed

src/Core/Cruzer.php

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -107,26 +107,6 @@ function _status( $status, $formated = true, $statusFor='default' ){
107107
}
108108
}
109109

110-
if( !function_exists('_formatFlightTime')){
111-
function _formatFlightTime( $time, $full=true ){
112-
$newTime1 = explode('T',$time);
113-
if( isset($newTime1[1]) ){
114-
$newTime2 = str_replace('+','-', $newTime1[1]);
115-
$newTime = explode('-', $newTime2);
116-
if( is_array($newTime) && count($newTime)){
117-
if( $full === true ){
118-
$format['time'] = $newTime[0];
119-
if(isset($newTime) && count($newTime)>1 ) $format['deduction'] = $newTime[1];
120-
$format['date'] = $newTime1[0];
121-
return $format;
122-
} else{
123-
return $newTime[0];
124-
}
125-
}
126-
}
127-
}
128-
}
129-
130110
if( !function_exists('__status')){
131111
function __status( $status, $formated = true, $statusFor='default' ){
132112
echo _status($status, $formated, $statusFor);

src/Core/Handler.php

Lines changed: 0 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -14,96 +14,6 @@ class Handler {
1414
protected $debugbar;
1515

1616
public function initilize( ) {
17-
//get dotenv
18-
$dotenv = new \Dotenv\Dotenv(ROOT_DIR);
19-
$dotenv->load();
20-
21-
date_default_timezone_set( env('APP_TIMEZONE', 'Asia/Calcutta'));
22-
define('ERROR_LEVEL', env('APP_ENV', 'production'));
23-
define('DEBUG_ERROR', env('APP_DEBUG', 'On'));
24-
25-
switch (ERROR_LEVEL) {
26-
case 'development':
27-
ini_set('display_startup_errors',1);
28-
ini_set('display_errors', DEBUG_ERROR);
29-
error_reporting(E_ALL);
30-
break;
31-
case 'testing' : error_reporting( E_ALL ^ E_NOTICE );
32-
ini_set('display_errors', DEBUG_ERROR); break;
33-
case 'production' : ini_set('display_errors', DEBUG_ERROR); break;
34-
default : error_reporting( E_ALL );
35-
ini_set('display_errors', DEBUG_ERROR); break;
36-
}
37-
38-
if(!defined('DS')) define('DS', DIRECTORY_SEPARATOR);
39-
define('APP_DIR', env('APP_DIR','App'));
40-
define('APP_URL', env('APP_URL'));
41-
define('APP_UNDER_DIR', env('APP_UNDER_DIR'));
42-
define('APP_TITLE', env('APP_NAME'));
43-
define('VIEW_DIR', env('VIEW_DIR','Views'));
44-
define('CONTROLLER_DIR', env('CONTROLLER_DIR','Controllers'));
45-
define('UPLOAD_DIR', env('UPLOAD_DIR'));
46-
define('THEME_DIR', env('THEME_DIR'));
47-
define('THEME_PATH', APP_URL.APP_DIR.DS.THEME_DIR.DS);
48-
define('MODULE_DIR', env('MODULE_DIR'));
49-
define('META_DESCRIPTION', 'Cruzer Framework');
50-
define('META_KEYWORDS', 'Cruzer Framework');
51-
define('COPYRIGHT', env('APP_NAME'));
52-
define('COPYRIGHT_URL', 'https://www.cruzersoftwares.com');
53-
define('ADMIN_DIR', env('ADMIN_DIR'));
54-
define('ADMIN_PATH', APP_URL.DS.ADMIN_DIR.DS);
55-
define('ADMIN_LOGIN_REDIRECT', ADMIN_PATH.'dashboard');
56-
define('ADMIN_LOGOUT_REDIRECT', ADMIN_PATH.'auth');
57-
require_once APP_DIR.DS."Config".DS."app.php";
58-
}
59-
60-
public function enableDebuger( ) {
61-
//include tracy
62-
Debugger::enable(Debugger::DETECT, LOG_DIR);
63-
Debugger::$strictMode = true;
64-
$this->getDebuger();
65-
// Debugger::$logSeverity = E_NOTICE | E_WARNING;
66-
// Debugger::$email = 'admin@example.com';
67-
68-
/* Debugger::log('Unexpected error'); // text message
69-
// Debugger::log($e, Debugger::ERROR); // also sends an email notification
70-
71-
// Debugger::dump([10, 20.2, true, null, 'hello']);
72-
73-
// //log errors to the chrom console.
74-
// Debugger::fireLog('Hello World');
75-
// Debugger::fireLog($_SERVER);
76-
// Debugger::fireLog(new Exception('Test Exception'));
77-
// Debugger::timer();
78-
// sleep(2);
79-
// echo $elapsed = Debugger::timer();*/
80-
81-
//use monolog for logging
82-
// use Monolog\Logger;
83-
// use Monolog\Handler\StreamHandler;
84-
85-
// // create a log channel
86-
// $logger = new Logger('Cruzer');
87-
// $logger->pushHandler(new StreamHandler(__DIR__ . '/log/cruzer.log', Logger::DEBUG));
88-
89-
// // add records to the log
90-
// $logger->warning('Foo');
91-
// $logger->error('Bar');
92-
// $logger->info('My logger is now ready');
93-
// $logger->info('Adding a new user', array('username' => 'Seldaek'));
94-
}
95-
96-
public function getDebuger(){
97-
return $this->debugbar = new StandardDebugBar();
98-
}
99-
100-
public function renderDebugBar(){
101-
$debugbarRenderer = $this->debugbar->getJavascriptRenderer()->setBaseUrl(DEBUG_DIR);
102-
echo "<html> <head>". $debugbarRenderer->renderHead(). "</head> <body> ".$debugbarRenderer->render()."</body> </html>";
103-
}
104-
105-
public function addMessage( $message, $tab = 'messages'){
106-
$this->debugbar[$tab]->addMessage($message);
10717
}
10818

10919
}

src/Core/Routes.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,27 @@ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQ
4949
$kernel->terminate($request, $response);
5050
}
5151

52-
public function map($path, $controller) {
53-
$this->routes->add( $path, new Route( $path, array('_controller' => $controller )));
52+
public function addRoute($path, $controller, $method = null) {
53+
if( isset($method) && $method!=null){
54+
$method = explode('|',$method);
55+
}
56+
$this->routes->add( $path, new Route( $path, array('_controller' => $controller ), [], [], '', [], $method ));
57+
}
58+
59+
public function add($method, $path, $controller) {
60+
$this->addRoute($path, $controller, $method );
61+
}
62+
63+
public function get($path, $controller) {
64+
$this->addRoute($path, $controller,'GET');
65+
}
66+
67+
public function post($path, $controller) {
68+
$this->addRoute($path, $controller,'POST');
69+
}
70+
71+
public function all($path, $controller) {
72+
$this->addRoute($path, $controller);
5473
}
5574

5675
public function on($event, $callback) {

0 commit comments

Comments
 (0)