mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
Merge branch '3.3.x'
This commit is contained in:
commit
65ea56f0e2
1 changed files with 15 additions and 17 deletions
|
@ -15,18 +15,16 @@ namespace phpbb\console;
|
||||||
|
|
||||||
use phpbb\exception\exception_interface;
|
use phpbb\exception\exception_interface;
|
||||||
use Symfony\Component\Console\ConsoleEvents;
|
use Symfony\Component\Console\ConsoleEvents;
|
||||||
use Symfony\Component\Console\Event\ConsoleExceptionEvent;
|
use Symfony\Component\Console\Event\ConsoleErrorEvent;
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
|
|
||||||
class exception_subscriber implements EventSubscriberInterface
|
class exception_subscriber implements EventSubscriberInterface
|
||||||
{
|
{
|
||||||
/**
|
/** @var \phpbb\language\language */
|
||||||
* @var \phpbb\language\language
|
|
||||||
*/
|
|
||||||
protected $language;
|
protected $language;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct method
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param \phpbb\language\language $language Language object
|
* @param \phpbb\language\language $language Language object
|
||||||
*/
|
*/
|
||||||
|
@ -36,30 +34,30 @@ class exception_subscriber implements EventSubscriberInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This listener is run when the ConsoleEvents::EXCEPTION event is triggered.
|
* This listener is run when the ConsoleEvents::ERROR event is triggered.
|
||||||
* It translate the exception message. If din debug mode the original exception is embedded.
|
* It translate the error message. If in debug mode the original exception is embedded.
|
||||||
*
|
*
|
||||||
* @param ConsoleExceptionEvent $event
|
* @param ConsoleErrorEvent $event
|
||||||
*/
|
*/
|
||||||
public function on_exception(ConsoleExceptionEvent $event)
|
public function on_error(ConsoleErrorEvent $event)
|
||||||
{
|
{
|
||||||
$original_exception = $event->getException();
|
$original_exception = $event->getError();
|
||||||
|
|
||||||
if ($original_exception instanceof exception_interface)
|
if ($original_exception instanceof exception_interface)
|
||||||
{
|
{
|
||||||
$parameters = array_merge(array($original_exception->getMessage()), $original_exception->get_parameters());
|
$parameters = array_merge([$original_exception->getMessage()], $original_exception->get_parameters());
|
||||||
$message = call_user_func_array(array($this->language, 'lang'), $parameters);
|
$message = call_user_func_array([$this->language, 'lang'], $parameters);
|
||||||
|
|
||||||
$exception = new \RuntimeException($message , $original_exception->getCode(), $original_exception);
|
$exception = new \RuntimeException($message , $original_exception->getCode(), $original_exception);
|
||||||
|
|
||||||
$event->setException($exception);
|
$event->setError($exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function getSubscribedEvents()
|
static public function getSubscribedEvents()
|
||||||
{
|
{
|
||||||
return array(
|
return [
|
||||||
ConsoleEvents::EXCEPTION => 'on_exception',
|
ConsoleEvents::ERROR => 'on_error',
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue