Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
framework
Validator
Exception.php
Go to the documentation of this file.
1
<?php
8
namespace
Magento\Framework\Validator
;
9
10
use
Magento\Framework\Exception\InputException
;
11
use
Magento\Framework\Phrase
;
12
use
Magento\Framework\Message\AbstractMessage
;
13
use
Magento\Framework\Message\Error
;
14
21
class
Exception
extends
InputException
22
{
26
protected
$messages
= [];
27
36
public
function
__construct
(
37
Phrase
$phrase
=
null
,
38
\
Exception
$cause =
null
,
39
array
$messages
= [],
40
$code
= 0
41
) {
42
if
(!empty(
$messages
)) {
43
$message
=
''
;
44
foreach
(
$messages
as $propertyMessages) {
45
foreach
($propertyMessages as $propertyMessage) {
46
if
(
$message
) {
47
$message
.= PHP_EOL;
48
}
49
$message
.= $propertyMessage;
50
$this->
addMessage
(
new
Error
($propertyMessage));
51
}
52
}
53
$phrase
=
new
Phrase
(
$message
);
54
}
55
parent::__construct(
$phrase
, $cause,
$code
);
56
}
57
64
public
function
addMessage
(
AbstractMessage
$message
)
65
{
66
if
(!isset($this->messages[
$message
->getType()])) {
67
$this->messages[
$message
->getType()] = [];
68
}
69
$this->messages[
$message
->getType()][] =
$message
;
70
return
$this;
71
}
72
79
public
function
getMessages
(
$type
=
''
)
80
{
81
if
(
''
==
$type
) {
82
$allMessages = [];
83
foreach
($this->messages as
$messages
) {
84
$allMessages = array_merge($allMessages,
$messages
);
85
}
86
return
$allMessages;
87
}
88
return
$this->messages[
$type
] ?? [];
89
}
90
}
Magento\Framework\Exception\LocalizedException\$phrase
$phrase
Definition:
LocalizedException.php:22
Magento\Framework\Validator\Exception
Definition:
Exception.php:21
Magento\Framework\Message\Error
Definition:
Error.php:11
Magento\Framework\Validator\Exception\$messages
$messages
Definition:
Exception.php:26
Magento\Framework\Validator\Exception\getMessages
getMessages($type='')
Definition:
Exception.php:79
Magento\Framework\Message\AbstractMessage
Definition:
AbstractMessage.php:14
Magento\Framework\Validator\Exception\addMessage
addMessage(AbstractMessage $message)
Definition:
Exception.php:64
$message
$message
Definition:
notifications.php:7
Magento\Framework\Exception\InputException
Definition:
InputException.php:17
$type
$type
Definition:
item.phtml:13
Magento\Framework\Phrase
Definition:
Phrase.php:17
Magento\Framework\Phrase
Magento\Framework\Validator
Definition:
AbstractValidator.php:6
Magento\Framework\Validator\Exception\__construct
__construct(Phrase $phrase=null, \Exception $cause=null, array $messages=[], $code=0)
Definition:
Exception.php:36
$code
$code
Definition:
info.phtml:12