Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AbstractAggregateException.php
Go to the documentation of this file.
1 <?php
8 
10 
16 {
22  protected $errors = [];
23 
29  protected $originalPhrase;
30 
36  private $addErrorCalls = 0;
37 
45  public function __construct(Phrase $phrase, \Exception $cause = null, $code = 0)
46  {
47  $this->originalPhrase = $phrase;
48  parent::__construct($phrase, $cause, $code);
49  }
50 
57  public function addError(Phrase $phrase)
58  {
59  $this->addErrorCalls++;
60  if (empty($this->errors)) {
61  if (1 === $this->addErrorCalls) {
62  // First call: simply overwrite the phrase and message
63  $this->phrase = $phrase;
64  $this->message = $phrase->render();
65  $this->logMessage = null;
66  } elseif (2 === $this->addErrorCalls) {
67  // Second call: store the error from the first call and the second call in the array
68  // restore the phrase to its original value
69  $this->errors[] = new LocalizedException($this->phrase);
70  $this->errors[] = new LocalizedException($phrase);
71  $this->phrase = $this->originalPhrase;
72  $this->message = $this->originalPhrase->render();
73  $this->logMessage = null;
74  }
75  } else {
76  // All subsequent calls after the second should reach here
77  $this->errors[] = new LocalizedException($phrase);
78  }
79  return $this;
80  }
81 
87  public function addException(LocalizedException $exception)
88  {
89  $this->addErrorCalls++;
90  $this->errors[] = $exception;
91  return $this;
92  }
93 
99  public function wasErrorAdded()
100  {
101  return (0 < $this->addErrorCalls);
102  }
103 
107  public function getErrors()
108  {
109  return $this->errors;
110  }
111 }
__construct(Phrase $phrase, \Exception $cause=null, $code=0)
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
$code
Definition: info.phtml:12