Memcache, refactoring, View helpers, #16

git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/branches/evo@124 4cb57b5f-5bbd-dd11-951b-001d605cbbc5
This commit is contained in:
pzinovkin
2010-03-13 23:33:46 +00:00
parent 4a22759e3d
commit 8fc917dca2
19 changed files with 706 additions and 147 deletions

View File

@ -13,7 +13,7 @@ class ErrorAction extends ViewAction
{
/**
* @var Exception
* @var ErrorException
*/
protected $exception;
@ -36,12 +36,12 @@ class ErrorAction extends ViewAction
return '/static/' . $this->template;
}
protected function sendHttpCode($code)
protected function sendHttpCode()
{
if (headers_sent()) {
return;
}
switch ($code) {
switch ($this->template) {
case 404:
header('HTTP/1.0 404 Not Found');
break;
@ -50,9 +50,40 @@ class ErrorAction extends ViewAction
}
}
protected function logError()
{
if ($this->template = 500) {
$error = 0;
$ex = $this->exception;
if ($ex instanceof ErrorException) {
$error = $ex->getSeverity();
}
switch ($error) {
case E_NOTICE:
$error = 'Notice';
break;
case E_WARNING:
$error = 'Warning';
break;
case E_ERROR:
$error = 'Fatal Error';
break;
default:
$error = 'Unknown Error';
break;
}
$message = 'PHP ' . $error . ': ' . $ex->getMessage() . ' in ' . $ex->getFile()
. ' on line ' . $ex->getLine();
error_log($message);
}
}
public function fetch()
{
$this->sendHTTPCode($this->template);
$this->logError();
$this->sendHTTPCode();
return $this->view->fetch($this->getTemplate());
}
}