1 | <?php |
||
16 | class base extends \Exception |
||
17 | { |
||
18 | /** |
||
19 | * Null if the message is a string, array if the message was submitted as an array |
||
20 | * @var string|array |
||
21 | */ |
||
22 | protected $message_full; |
||
23 | |||
24 | /** |
||
25 | * Send a string to translate all of the portions with the parent message |
||
26 | * (typically used to format a string with the given message portions). |
||
27 | * Null to ignore. Default: Null |
||
28 | * @var string|null |
||
29 | */ |
||
30 | protected $parent_message = null; |
||
31 | |||
32 | protected $previous; |
||
33 | |||
34 | /** |
||
35 | * Constructor |
||
36 | * |
||
37 | * Different from normal exceptions in that we do not enforce $message to be a string. |
||
38 | * |
||
39 | * @param string|array $message |
||
40 | * @param int $code |
||
41 | * @param \Exception $previous |
||
42 | * @access public |
||
43 | */ |
||
44 | 32 | public function __construct($message = null, $code = 0, \Exception $previous = null) |
|
62 | |||
63 | /** |
||
64 | * Translate this exception |
||
65 | * |
||
66 | * @param \phpbb\language\language $translator |
||
67 | * @return array|string |
||
68 | * @access public |
||
69 | */ |
||
70 | 32 | public function get_message(\phpbb\language\language $translator) |
|
74 | |||
75 | /** |
||
76 | * Translate all portions of the message sent to the exception |
||
77 | * |
||
78 | * Goes through each element of the array and tries to translate them |
||
79 | * |
||
80 | * @param \phpbb\language\language $translator |
||
81 | * @return array|string Array if $parent_message === null else a string |
||
82 | * @access protected |
||
83 | */ |
||
84 | 32 | protected function translate_portions(\phpbb\language\language $translator) |
|
123 | |||
124 | /** |
||
125 | * Add our language file |
||
126 | * |
||
127 | * @param \phpbb\language\language $translator |
||
128 | * @return null |
||
129 | * @access public |
||
130 | */ |
||
131 | 32 | public function add_lang(\phpbb\language\language $translator) |
|
147 | |||
148 | /** |
||
149 | * Output a string of this error message |
||
150 | * |
||
151 | * This will hopefully be never called, always catch the expected exceptions |
||
152 | * and call get_message to translate them into an error that a user canunderstand |
||
153 | * |
||
154 | * @return string |
||
155 | * @access public |
||
156 | */ |
||
157 | public function __toString() |
||
161 | } |
||
162 |