phpBB

Code Changes

File: phpbb/event/kernel_exception_subscriber.php

  Unmodified   Added   Modified   Removed
Line 14Line 14
namespace phpbb\event;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;

namespace phpbb\event;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;

 
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;

use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;

use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;

use Symfony\Component\HttpKernel\Exception\HttpException;

 
use Symfony\Component\HttpFoundation\Response;

class kernel_exception_subscriber implements EventSubscriberInterface

use Symfony\Component\HttpFoundation\Response;

class kernel_exception_subscriber implements EventSubscriberInterface

Line 32Line 33
	* @var \phpbb\user
*/
protected $user;

	* @var \phpbb\user
*/
protected $user;

 

/** @var \phpbb\request\type_cast_helper */
protected $type_caster;


/**
* Construct method


/**
* Construct method

Line 43Line 47
	{
$this->template = $template;
$this->user = $user;

	{
$this->template = $template;
$this->user = $user;

 
		$this->type_caster = new \phpbb\request\type_cast_helper();

	}

/**

	}

/**

Line 53Line 58
	*/
public function on_kernel_exception(GetResponseForExceptionEvent $event)
{

	*/
public function on_kernel_exception(GetResponseForExceptionEvent $event)
{

		page_header($this->user->lang('INFORMATION'));


 
		$exception = $event->getException();

		$exception = $event->getException();

 

$message = $exception->getMessage();
$this->type_caster->set_var($message, $message, 'string', true, false);

if ($exception instanceof \phpbb\exception\exception_interface)
{
$message = call_user_func_array(array($this->user, 'lang'), array_merge(array($message), $exception->get_parameters()));
}

// Show <strong> text in bold
$message = preg_replace('#&lt;(/?strong)&gt;#i', '<$1>', $message);

if (!$event->getRequest()->isXmlHttpRequest())
{
page_header($this->user->lang('INFORMATION'));


$this->template->assign_vars(array(


$this->template->assign_vars(array(

			'MESSAGE_TITLE'		=> $this->user->lang('INFORMATION'),
'MESSAGE_TEXT' => $exception->getMessage(),

				'MESSAGE_TITLE' => $this->user->lang('INFORMATION'),
'MESSAGE_TEXT' => $message,

		));

$this->template->set_filenames(array(

		));

$this->template->set_filenames(array(

			'body'	=> 'message_body.html',

				'body' => 'message_body.html',

		));

page_footer(true, false, false);


		));

page_footer(true, false, false);


		$status_code = $exception instanceof HttpException ? $exception->getStatusCode() : 500;
$response = new Response($this->template->assign_display('body'), $status_code);
























			$response = new Response($this->template->assign_display('body'), 500);
}
else
{
$data = array();

if (!empty($message))
{
$data['message'] = $message;
}

if (defined('DEBUG'))
{
$data['trace'] = $exception->getTrace();
}

$response = new JsonResponse($data, 500);
}

if ($exception instanceof HttpExceptionInterface)
{
$response->setStatusCode($exception->getStatusCode());
$response->headers->add($exception->getHeaders());
}


		$event->setResponse($response);
}


		$event->setResponse($response);
}