Verzeichnisstruktur phpBB-3.2.0
- Veröffentlicht
- 06.01.2017
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
exception_subscriber.php
01 <?php
02 /**
03 *
04 * This file is part of the phpBB Forum Software package.
05 *
06 * @copyright (c) phpBB Limited <https://www.phpbb.com>
07 * @license GNU General Public License, version 2 (GPL-2.0)
08 *
09 * For full copyright and license information, please see
10 * the docs/CREDITS.txt file.
11 *
12 */
13
14 namespace phpbb\console;
15
16 use phpbb\exception\exception_interface;
17 use Symfony\Component\Console\ConsoleEvents;
18 use Symfony\Component\Console\Event\ConsoleExceptionEvent;
19 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
20
21 class exception_subscriber implements EventSubscriberInterface
22 {
23 /**
24 * @var \phpbb\language\language
25 */
26 protected $language;
27
28 /**
29 * Construct method
30 *
31 * @param \phpbb\language\language $language Language object
32 * @param bool $debug Debug mode
33 */
34 public function __construct(\phpbb\language\language $language, $debug = false)
35 {
36 $this->language = $language;
37 $this->debug = $debug;
38 }
39
40 /**
41 * This listener is run when the ConsoleEvents::EXCEPTION event is triggered.
42 * It translate the exception message. If din debug mode the original exception is embedded.
43 *
44 * @param ConsoleExceptionEvent $event
45 */
46 public function on_exception(ConsoleExceptionEvent $event)
47 {
48 $original_exception = $event->getException();
49
50 if ($original_exception instanceof exception_interface)
51 {
52 $parameters = array_merge(array($original_exception->getMessage()), $original_exception->get_parameters());
53 $message = call_user_func_array(array($this->language, 'lang'), $parameters);
54
55 if ($this->debug)
56 {
57 $exception = new \RuntimeException($message , $original_exception->getCode(), $original_exception);
58 }
59 else
60 {
61 $exception = new \RuntimeException($message , $original_exception->getCode());
62 }
63
64 $event->setException($exception);
65 }
66 }
67
68 static public function getSubscribedEvents()
69 {
70 return array(
71 ConsoleEvents::EXCEPTION => 'on_exception',
72 );
73 }
74 }
75