aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/event/kernel_exception_subscriber.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/phpbb/event/kernel_exception_subscriber.php')
-rw-r--r--phpBB/phpbb/event/kernel_exception_subscriber.php40
1 files changed, 28 insertions, 12 deletions
diff --git a/phpBB/phpbb/event/kernel_exception_subscriber.php b/phpBB/phpbb/event/kernel_exception_subscriber.php
index 1ee771cfe7..373e59b0c8 100644
--- a/phpBB/phpbb/event/kernel_exception_subscriber.php
+++ b/phpBB/phpbb/event/kernel_exception_subscriber.php
@@ -16,6 +16,7 @@ namespace phpbb\event;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
+use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpFoundation\Response;
@@ -23,16 +24,25 @@ use Symfony\Component\HttpFoundation\Response;
class kernel_exception_subscriber implements EventSubscriberInterface
{
/**
+ * Set to true to show full exception messages
+ *
+ * @var bool
+ */
+ protected $debug;
+
+ /**
* Template object
+ *
* @var \phpbb\template\template
*/
protected $template;
/**
- * User object
- * @var \phpbb\user
+ * Language object
+ *
+ * @var \phpbb\language\language
*/
- protected $user;
+ protected $language;
/** @var \phpbb\request\type_cast_helper */
protected $type_caster;
@@ -40,13 +50,15 @@ class kernel_exception_subscriber implements EventSubscriberInterface
/**
* Construct method
*
- * @param \phpbb\template\template $template Template object
- * @param \phpbb\user $user User object
+ * @param \phpbb\template\template $template Template object
+ * @param \phpbb\language\language $language Language object
+ * @param bool $debug Set to true to show full exception messages
*/
- public function __construct(\phpbb\template\template $template, \phpbb\user $user)
+ public function __construct(\phpbb\template\template $template, \phpbb\language\language $language, $debug = false)
{
+ $this->debug = $debug || defined('DEBUG');
$this->template = $template;
- $this->user = $user;
+ $this->language = $language;
$this->type_caster = new \phpbb\request\type_cast_helper();
}
@@ -65,7 +77,11 @@ class kernel_exception_subscriber implements EventSubscriberInterface
if ($exception instanceof \phpbb\exception\exception_interface)
{
- $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($message), $exception->get_parameters()));
+ $message = $this->language->lang_array($message, $exception->get_parameters());
+ }
+ else if (!$this->debug && $exception instanceof NotFoundHttpException)
+ {
+ $message = $this->language->lang('PAGE_NOT_FOUND');
}
// Show <strong> text in bold
@@ -73,10 +89,10 @@ class kernel_exception_subscriber implements EventSubscriberInterface
if (!$event->getRequest()->isXmlHttpRequest())
{
- page_header($this->user->lang('INFORMATION'));
+ page_header($this->language->lang('INFORMATION'));
$this->template->assign_vars(array(
- 'MESSAGE_TITLE' => $this->user->lang('INFORMATION'),
+ 'MESSAGE_TITLE' => $this->language->lang('INFORMATION'),
'MESSAGE_TEXT' => $message,
));
@@ -97,7 +113,7 @@ class kernel_exception_subscriber implements EventSubscriberInterface
$data['message'] = $message;
}
- if (defined('DEBUG'))
+ if ($this->debug)
{
$data['trace'] = $exception->getTrace();
}
@@ -114,7 +130,7 @@ class kernel_exception_subscriber implements EventSubscriberInterface
$event->setResponse($response);
}
- public static function getSubscribedEvents()
+ static public function getSubscribedEvents()
{
return array(
KernelEvents::EXCEPTION => 'on_kernel_exception',