本文整理汇总了PHP中Symfony\Component\Debug\Exception\FlattenException::getLine方法的典型用法代码示例。如果您正苦于以下问题:PHP FlattenException::getLine方法的具体用法?PHP FlattenException::getLine怎么用?PHP FlattenException::getLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Debug\Exception\FlattenException
的用法示例。
在下文中一共展示了FlattenException::getLine方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: exceptionAction
public function exceptionAction(FlattenException $exception)
{
$this->view->status_code = $exception->getStatusCode();
$this->view->message = $exception->getMessage();
$this->view->file = $this->getShortFileName($exception->getFile());
$this->view->line = $exception->getLine();
$this->view->trace = $this->parseTrace($exception->getTrace());
return $this->renderTo('@HideksFramework/templates/exception.html');
}
示例2: decodeException
/**
* This method is a temporary port of _drupal_decode_exception().
*
* @todo This should get refactored. FlattenException could use some
* improvement as well.
*
* @param \Symfony\Component\Debug\Exception\FlattenException $exception
* The flattened exception.
*
* @return array
* An array of string-substitution tokens for formatting a message about the
* exception.
*/
protected function decodeException(FlattenException $exception)
{
$message = $exception->getMessage();
$backtrace = $exception->getTrace();
// This value is missing from the stack for some reason in the
// FlattenException version of the backtrace.
$backtrace[0]['line'] = $exception->getLine();
// For database errors, we try to return the initial caller,
// skipping internal functions of the database layer.
if (strpos($exception->getClass(), 'DatabaseExceptionWrapper') !== FALSE) {
// A DatabaseExceptionWrapper exception is actually just a courier for
// the original PDOException. It's the stack trace from that exception
// that we care about.
$backtrace = $exception->getPrevious()->getTrace();
$backtrace[0]['line'] = $exception->getLine();
// The first element in the stack is the call, the second element gives us the caller.
// We skip calls that occurred in one of the classes of the database layer
// or in one of its global functions.
$db_functions = array('db_query', 'db_query_range');
while (!empty($backtrace[1]) && ($caller = $backtrace[1]) && (strpos($caller['namespace'], 'Drupal\\Core\\Database') !== FALSE || strpos($caller['class'], 'PDO') !== FALSE) || in_array($caller['function'], $db_functions)) {
// We remove that call.
array_shift($backtrace);
}
}
$caller = Error::getLastCaller($backtrace);
return array('%type' => $exception->getClass(), '!message' => String::checkPlain($message), '%function' => $caller['function'], '%file' => $caller['file'], '%line' => $caller['line'], 'severity_level' => WATCHDOG_ERROR);
}
示例3: checkRepeat
/**
* Check last send time
*
* @param FlattenException $exception
* @return bool
*/
private function checkRepeat(FlattenException $exception)
{
$key = md5($exception->getMessage() . ':' . $exception->getLine() . ':' . $exception->getFile());
$file = $this->errorsDir . '/' . $key;
$time = is_file($file) ? file_get_contents($file) : 0;
if ($time < time()) {
file_put_contents($file, time() + $this->repeatTimeout);
return false;
}
return true;
}