/** * Get View Path * @param string $name * @return bool */ private function getViewPath($name) { $locations = ['']; !isset(DfApp::app()->router->controller) ?: ($locations[] = DfApp::app()->router->controller); !isset(DfApp::app()->router->action) ?: ($locations[] = DfApp::app()->router->action); return $this->findView($locations, $name); }
/** * Log * @param string $error * @param $location * @param string $type * @param string $level */ public function log($error, $location, $type = DfLogger::TYPE_INFO, $level = DfLogger::LEVEL_LOG) { DfApp::app()->logger->log($this->componentName, $error, $location, $type, $level); }
/** * Config Reading * @param $config */ private static function configRead($config) { if (isset($config['app_path'])) { static::$appPath = trim($config['app_path'], '/'); } if (isset($config['components'])) { if (isset($config['components']['db'])) { DfApp::app()->db = new DfDbConnection($config['components']['db']['link'], $config['components']['db']['user'], $config['components']['db']['password']); } } if (isset($config['logger']['path'])) { DfApp::app()->logger = new DfLogger($config['logger']['path']); } else { DfApp::app()->logger = new DfLogger(); } if (isset($config['errors'])) { if (isset($config['errors']['display'])) { switch ($config['errors']['display']) { case true: ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(isset($config['errors']['level']) ? $config['errors']['level'] : -1); break; case false: default: ini_set('display_errors', 0); ini_set('display_startup_errors', 0); error_reporting(0); break; } } if (isset($config['errors']['debug'])) { DfErrorHandler::$debug = $config['errors']['debug']; } if (isset($config['errors']['error_call'])) { DfErrorHandler::$errorCall = $config['errors']['error_call']; } } if (isset($config['router']['default'])) { if (isset($config['router']['default']['controller'])) { DfApp::app()->router->controller = $config['router']['default']['controller']; } if (isset($config['router']['default']['action'])) { DfApp::app()->router->action = $config['router']['default']['action']; } if (isset($config['router']['default']['id'])) { DfApp::app()->router->id = $config['router']['default']['id']; } } }
/** * @depends DfAppTest::testSetupEx */ public function testStop() { $this->assertEquals(true, is_numeric(DfApp::app()->timer->stop())); $this->assertEquals(true, is_numeric(DfApp::app()->timer->stop('1'))); }
/** * @depends testLog */ public function testSave() { DfApp::app()->logger->path = DfTests::$testDir . 'log.txt'; DfApp::app()->logger->save(); $this->assertEquals(true, file_exists(DfTests::$testDir . 'log.txt')); }
/** * Get instance of DfDbConnection * For customization can be overloading in called classes * @return DfDbConnection */ public static function getDb() { return DfApp::app()->db; }
/** * execute */ private function execute() { if (empty(DfApp::app()->getRuntimePath())) { throw new DfSetupException("No defined RuntimePath"); } $controllerName = ucwords($this->controller) . 'Controller'; $actionName = 'action' . ucwords($this->action); if (!class_exists($controllerName)) { throw new DfNotFoundException("Unable to find controller: {$this->controller}"); } $_controller = new $controllerName(); if (!method_exists($_controller, $actionName)) { throw new DfNotFoundException("Unable to find action: {$this->controller}/{$this->action}"); } call_user_func([$_controller, 'beforeAction']); if (!empty($this->id)) { call_user_func([$_controller, $actionName], $this->id); } else { call_user_func([$_controller, $actionName]); } call_user_func([$_controller, 'afterAction']); }
/** * Render Error Page * @param DfException $ex */ private static function renderErrorPage($ex) { if (!empty(self::$errorCall)) { DfApp::app()->router->callByArray(self::$errorCall); } else { self::includePage($ex); } }
?> </div> </h4> </div> <div class="panel-body"> <table class="table table-borderless table-condensed"> <?php DfErrorHandler::showSources($ex->getFile(), false, $ex->getLine()); ?> </table> </div> </div> <h3>Application dump</h3> <?php var_dump(DfApp::app()); ?> <h3>Stack Trace</h3> <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true"> <?php foreach ($ex->getTrace() as $id => $call) { ?> <?php if (isset($call['file'])) { ?> <div class="panel panel-default"> <div class="panel-heading" role="tab" id="heading<?php echo $id; ?>