/** * @param string $message * @param int $code * @param int $severity * @param string $filename * @param int $lineno * @param \Exception $previous */ public function __construct($message = '', $code = 0, $severity = 1, $filename = __FILE__, $lineno = __LINE__, \Exception $previous = null) { parent::__construct($message, $code, $severity, $filename, $lineno, $previous); try { AppKernel::log('error', $this->getMessage(), array('code' => $code, 'exception' => $this)); } catch (\Exception $e) { } }
/** * @param string $message * @param int $code * @param \Exception $previous */ public function __construct($message = '', $code = 0, \Exception $previous = null) { parent::__construct($message, $code, $previous); try { AppKernel::log('error', $this->getMessage(), array('code' => $code, 'exception' => $this)); } catch (\Exception $e) { } }
// FrontController usage // ---------------------------------- /** * @TODOS * - security * - multiple templates / actions rendering in one page */ // front controller creation $fctrl = \MVCFundamental\FrontController::getInstance(array('mode' => 'dev', 'default_controller_name' => '\\Demo\\DefaultController', 'controller_locator' => function ($name) { $class = '\\Demo\\' . ucfirst($name) . 'Controller'; return class_exists($class) ? $class : null; })); // load some predefined settings $helper = new \Demo\TestHelper(); // test a log message \MVCFundamental\AppKernel::log('info', 'Test log for request ' . $fctrl->get('request')->getUri()); // routing definitions $fctrl->addRoute('/', function () use($fctrl) { $req = $fctrl->get('request')->getUrl(); return $fctrl->get('template_engine')->renderDefault(<<<MESAGE <p><strong>Welcome in the demo!</strong> You will find below various routes to test the package.</p> <p>To learn how these routes are defined and a quick "how-to", have a look in the source code of file <code>demo/index.php</code>.</p> <p>To get last source updates or report a bug, see <a href="http://github.com/atelierspierrot/mvc-fundamental">the "atelierspierrot/mvc-fundamental" repository</a>.</p> <p>Calls of various routes and callbacks:</p> <ul> <li><a href="{$req}hello">/hello</a> : simple closure callback with no argument</li> <li><a href="{$req}hello/your-name">/hello/{name}</a> : simple closure callback with a "name" argument</li> <li><a href="{$req}hello/your-name/controller">/hello/{name}/controller</a> : a controller default action call with a "name" argument</li> <li><a href="{$req}hello/your-name/method">/hello/{name}/method</a> : a custom method of the default controller call with a "name" argument</li> <li><a href="{$req}hello/your-name/view">/hello/{name}/view</a> : a direct "view" file inclusion with a "name" argument</li> <li><a href="{$req}hello/your-name/myview">/hello/{name}/myview</a> : a controller action loading a "view" file with a "name" argument</li>