本文整理汇总了PHP中Error::render方法的典型用法代码示例。如果您正苦于以下问题:PHP Error::render方法的具体用法?PHP Error::render怎么用?PHP Error::render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Error
的用法示例。
在下文中一共展示了Error::render方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
public function render($vars = null)
{
// Autoloads
// juste avant l'affichage pour que les components soit tous déjà chargés pour les transmitions aux helpers
foreach ($this->_params["helpers"] as $key => $value) {
if (is_numeric($key)) {
$this->load($value);
} else {
$this->load($key, $value);
}
}
if ($vars != null) {
extract($vars);
}
if (file_exists("app/frontend/views/themes/" . $this->_defaultTheme . '/index.php')) {
include "app/frontend/views/themes/" . $this->_defaultTheme . '/index.php';
} else {
Error::render(3, $this->_defaultTheme);
}
}
示例2: testException
/**
* @expectedException Error
*/
public function testException()
{
$e = new Error(400, "This is message", 8);
$e->render();
}
示例3: handler
/**
* Replaces Kohana's `Kohana::exception_handler()` method. This does the
* same thing, but also adds email functionality and the ability to perform
* an action in response to the exception. These actions and emails are
* customizable per type in the config file for this module.
*
* @uses Kohana::exception_text
* @param \Exception $e
* @internal param \exception $object object
* @return boolean
*/
public static function handler(Exception $e)
{
try
{
$error = new Error();
// Get the exception information
$error->exception = $e;
$error->type = get_class($e);
$error->code = $e->getCode();
$error->message = $e->getMessage();
$error->file = $e->getFile();
$error->line = $e->getLine();
$error->request_initial = Request::initial();
// Create a text version of the exception
$error->text = Kohana_Exception::text($e);
if (Kohana::$is_cli)
{
// Display the text of the exception
echo "\n{$error->text}\n";
}
// Get the exception backtrace
$error->trace = $e->getTrace();
if ($e instanceof ErrorException)
{
if (version_compare(PHP_VERSION, '5.3', '<'))
{
// Workaround for a bug in ErrorException::getTrace() that exists in
// all PHP 5.2 versions. @see http://bugs.php.net/bug.php?id=45895
for ($i = count($error->trace) - 1;$i > 0;--$i)
{
if (isset($error->trace[$i - 1]['args']))
{
// Re-position the args
$error->trace[$i]['args'] = $error->trace[$i - 1]['args'];
// Remove the args
unset($error->trace[$i - 1]['args']);
}
}
}
}
if (!headers_sent() and (Kohana::$is_cli === false))
{
// Make sure the proper content type is sent with a 500 status
header('Content-Type: text/html; charset=' . Kohana::$charset, true, 500);
}
// Get the contents of the output buffer
$error->display = $error->render();
// Log the error
$error->log();
// Email the error
$error->email();
// Respond to the error
$error->action();
return true;
}
catch (Exception $e)
{
// Log an error.
if (is_object(Kohana::$log))
{
// Create a text version of the exception
$error = Kohana_Exception::text($e);
// Add this exception to the log
Kohana::$log->add(Log::ERROR, $error);
// Make sure the logs are written
Kohana::$log->write();
}
// Clean the output buffer if one exists
ob_get_level() and ob_clean();
// Display the exception text
header('HTTP/1.1 500 Internal Server Error');
echo "Unknown Error - Exception thrown in Error::handler()";
//.........这里部分代码省略.........
示例4: load
/**
* Permet de charger la View avec son template
* @return string Contenu de la View après son rendu, et avec le template. Oui monsieur !!! =)
*/
public function load()
{
header('HTTP/1.0 ' . $this->httpCode . ' ' . $this->httpCodes[$this->httpCode]);
$viewFile = APP . '/View/' . Path::ds($this->viewName) . '.php';
$templateFile = APP . '/Template/' . Path::ds($this->templateName) . '.php';
if (file_exists($viewFile)) {
extract(array_merge(compact('this'), $this->vars));
ob_start();
include $viewFile;
$content = ob_get_clean();
if (file_exists($templateFile)) {
include $templateFile;
return ob_get_clean();
} else {
return Error::render('missingTemplate', ['template' => $this->templateName]);
}
} else {
return Error::render('missingView', ['view' => $this->viewName]);
}
}
示例5: loadError
/**
* Carrega a página de erro de acordo com as configurações e mata a execução
* @param object $error instância de Exception
* @return void
*/
private function loadError($error)
{
Error::render($error->getCode(), $error->getMessage(), $error->getFile(), $error->getLine(), $error->getTraceAsString(), method_exists($error, 'getDetails') ? $error->getDetails() : '');
}