|
8 | 8 |
|
9 | 9 | use Magento\Framework\Phrase;
|
10 | 10 |
|
11 |
| -/** |
12 |
| - * @api |
13 |
| - */ |
14 |
| -abstract class AbstractAggregateException extends LocalizedException |
15 |
| -{ |
16 |
| - /** |
17 |
| - * The array of errors that have been added via the addError() method |
18 |
| - * |
19 |
| - * @var \Magento\Framework\Exception\LocalizedException[] |
20 |
| - */ |
21 |
| - protected $errors = []; |
22 |
| - |
23 |
| - /** |
24 |
| - * The original phrase |
25 |
| - * |
26 |
| - * @var \Magento\Framework\Phrase |
27 |
| - */ |
28 |
| - protected $originalPhrase; |
29 |
| - |
30 |
| - /** |
31 |
| - * An internal variable indicating how many time addError has been called |
32 |
| - * |
33 |
| - * @var int |
34 |
| - */ |
35 |
| - private $addErrorCalls = 0; |
36 |
| - |
37 |
| - /** |
38 |
| - * Initialize the exception |
39 |
| - * |
40 |
| - * @param \Magento\Framework\Phrase $phrase |
41 |
| - * @param \Exception $cause |
42 |
| - * @param int $code |
43 |
| - */ |
44 |
| - public function __construct(Phrase $phrase, \Exception $cause = null, $code = 0) |
45 |
| - { |
46 |
| - $this->originalPhrase = $phrase; |
47 |
| - parent::__construct($phrase, $cause, $code); |
48 |
| - } |
49 |
| - |
50 |
| - /** |
51 |
| - * Add new error into the list of exceptions |
52 |
| - * |
53 |
| - * @param \Magento\Framework\Phrase $phrase |
54 |
| - * @return $this |
55 |
| - */ |
56 |
| - public function addError(Phrase $phrase) |
57 |
| - { |
58 |
| - $this->addErrorCalls++; |
59 |
| - if (empty($this->errors)) { |
60 |
| - if (1 === $this->addErrorCalls) { |
61 |
| - // First call: simply overwrite the phrase and message |
62 |
| - $this->phrase = $phrase; |
63 |
| - $this->message = $phrase->render(); |
64 |
| - $this->logMessage = null; |
65 |
| - } elseif (2 === $this->addErrorCalls) { |
66 |
| - // Second call: store the error from the first call and the second call in the array |
67 |
| - // restore the phrase to its original value |
68 |
| - $this->errors[] = new LocalizedException($this->phrase); |
69 |
| - $this->errors[] = new LocalizedException($phrase); |
70 |
| - $this->phrase = $this->originalPhrase; |
71 |
| - $this->message = $this->originalPhrase->render(); |
72 |
| - $this->logMessage = null; |
73 |
| - } |
74 |
| - } else { |
75 |
| - // All subsequent calls after the second should reach here |
76 |
| - $this->errors[] = new LocalizedException($phrase); |
77 |
| - } |
78 |
| - return $this; |
79 |
| - } |
80 |
| - |
81 |
| - /** |
82 |
| - * @param LocalizedException $exception |
83 |
| - * @return $this |
84 |
| - */ |
85 |
| - public function addException(LocalizedException $exception)<?php |
86 |
| -/** |
87 |
| - * Copyright © Magento, Inc. All rights reserved. |
88 |
| - * See COPYING.txt for license details. |
89 |
| - */ |
90 |
| - |
91 |
| -namespace Magento\Framework\Exception; |
92 |
| - |
93 |
| -use Magento\Framework\Phrase; |
94 |
| - |
95 | 11 | /**
|
96 | 12 | * @api
|
97 | 13 | */
|
@@ -193,30 +109,3 @@ public function getErrors()
|
193 | 109 | return $this->errors;
|
194 | 110 | }
|
195 | 111 | }
|
196 |
| - |
197 |
| - { |
198 |
| - $this->addErrorCalls++; |
199 |
| - $this->errors[] = $exception; |
200 |
| - return $this; |
201 |
| - } |
202 |
| - |
203 |
| - /** |
204 |
| - * Should return true if someone has added different errors to this exception after construction |
205 |
| - * |
206 |
| - * @return bool |
207 |
| - */ |
208 |
| - public function wasErrorAdded() |
209 |
| - { |
210 |
| - return (0 < $this->addErrorCalls); |
211 |
| - } |
212 |
| - |
213 |
| - /** |
214 |
| - * Get the array of LocalizedException objects. Get an empty array if no errors were added. |
215 |
| - * |
216 |
| - * @return \Magento\Framework\Exception\LocalizedException[] |
217 |
| - */ |
218 |
| - public function getErrors() |
219 |
| - { |
220 |
| - return $this->errors; |
221 |
| - } |
222 |
| -} |
0 commit comments