-
-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #402 from phalcon/2.0.x
2.0.7
- Loading branch information
Showing
8 changed files
with
83 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
+------------------------------------------------------------------------+ | ||
| Phalcon Framework | | ||
+------------------------------------------------------------------------+ | ||
| Copyright (c) 2011-2012 Phalcon Team (http://www.phalconphp.com) | | ||
| Copyright (c) 2011-2015 Phalcon Team (http://www.phalconphp.com) | | ||
+------------------------------------------------------------------------+ | ||
| This source file is subject to the New BSD License that is bundled | | ||
| with this package in the file docs/LICENSE.txt. | | ||
|
@@ -15,15 +15,16 @@ | |
| Authors: Andres Gutierrez <[email protected]> | | ||
| Eduar Carvajal <[email protected]> | | ||
| Nikita Vershinin <[email protected]> | | ||
| Serghei Iakovlev <[email protected]> | | ||
+------------------------------------------------------------------------+ | ||
*/ | ||
namespace Phalcon\Error; | ||
|
||
use Phalcon\DI; | ||
use Phalcon\Di; | ||
use Phalcon\Logger\Formatter; | ||
|
||
class Handler | ||
{ | ||
|
||
/** | ||
* Registers itself as error and exception handler. | ||
* | ||
|
@@ -50,26 +51,26 @@ public static function register() | |
return; | ||
} | ||
|
||
$options = array( | ||
$options = [ | ||
'type' => $errno, | ||
'message' => $errstr, | ||
'file' => $errfile, | ||
'line' => $errline, | ||
'isError' => true, | ||
); | ||
]; | ||
|
||
static::handle(new Error($options)); | ||
}); | ||
|
||
set_exception_handler(function (\Exception $e) { | ||
$options = array( | ||
$options = [ | ||
'type' => $e->getCode(), | ||
'message' => $e->getMessage(), | ||
'file' => $e->getFile(), | ||
'line' => $e->getLine(), | ||
'isException' => true, | ||
'exception' => $e, | ||
); | ||
]; | ||
|
||
static::handle(new Error($options)); | ||
}); | ||
|
@@ -89,12 +90,16 @@ public static function register() | |
*/ | ||
public static function handle(Error $error) | ||
{ | ||
$di = DI::getDefault(); | ||
$config = $di->getShared('config'); | ||
$di = Di::getDefault(); | ||
$config = $di->getShared('config')->error; | ||
$type = static::getErrorType($error->type()); | ||
$message = "$type: {$error->message()} in {$error->file()} on line {$error->line()}"; | ||
|
||
$config->error->logger->log($message); | ||
if (isset($config->formatter) && $config->formatter instanceof Formatter) { | ||
$config->logger->setFormatter($config->formatter); | ||
} | ||
|
||
$config->logger->log($message); | ||
|
||
switch ($error->type()) { | ||
case E_WARNING: | ||
|
@@ -119,13 +124,13 @@ public static function handle(Error $error) | |
$view = $di->getShared('view'); | ||
$response = $di->getShared('response'); | ||
|
||
$dispatcher->setControllerName($config->error->controller); | ||
$dispatcher->setActionName($config->error->action); | ||
$dispatcher->setParams(array('error' => $error)); | ||
$dispatcher->setControllerName($config->controller); | ||
$dispatcher->setActionName($config->action); | ||
$dispatcher->setParams(['error' => $error]); | ||
|
||
$view->start(); | ||
$dispatcher->dispatch(); | ||
$view->render($config->error->controller, $config->error->action, $dispatcher->getParams()); | ||
$view->render($config->controller, $config->action, $dispatcher->getParams()); | ||
$view->finish(); | ||
|
||
return $response->setContent($view->getContent())->send(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Phalcon\Mvc\View; | ||
|
||
use \Phalcon\Mvc\View; | ||
|
||
class SmartyView extends View | ||
{ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
} | ||
|
||
public function setVar($key, $value, $nocache = false) | ||
{ | ||
$this->_viewParams[$key] = $value; | ||
$this->_viewParams["_" . $key] = $nocache; | ||
} | ||
} |