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
Message
ExceptionMessageFactory.php
Go to the documentation of this file.
1
<?php
7
namespace
Magento\Framework\Message
;
8
9
use
Magento\Framework\Exception\RuntimeException
;
10
11
class
ExceptionMessageFactory
implements
ExceptionMessageFactoryInterface
12
{
16
private
$messageFactory;
17
21
public
function
__construct
(
Factory
$messageFactory)
22
{
23
$this->messageFactory =
$messageFactory
;
24
}
25
29
public
function
createMessage
(\Exception $exception,
$type
=
MessageInterface::TYPE_ERROR
)
30
{
31
if
($exception instanceof \Exception) {
32
return
$this->messageFactory->create(
$type
)
33
->setText($exception->getMessage());
34
}
35
throw
new
RuntimeException
(
36
new
\
Magento
\Framework\
Phrase
(
"Exception instance doesn't match %1 type"
, [\Exception::class])
37
);
38
}
39
}
Magento\Framework\Message
Definition:
AbstractMessage.php:6
Magento\Framework\Exception\RuntimeException
Definition:
RuntimeException.php:11
Magento\Framework\Message\ExceptionMessageFactory\__construct
__construct(Factory $messageFactory)
Definition:
ExceptionMessageFactory.php:21
Magento\Framework\Message\ExceptionMessageFactory
Definition:
ExceptionMessageFactory.php:11
$type
$type
Definition:
item.phtml:13
Magento\Framework\Message\Factory
Definition:
Factory.php:14
Magento\Framework\Message\ExceptionMessageFactory\createMessage
createMessage(\Exception $exception, $type=MessageInterface::TYPE_ERROR)
Definition:
ExceptionMessageFactory.php:29
Magento
Magento\Framework\Message\MessageInterface\TYPE_ERROR
const TYPE_ERROR
Definition:
MessageInterface.php:24
Magento\Framework\Message\ExceptionMessageFactoryInterface
Definition:
ExceptionMessageFactoryInterface.php:15
Magento\Framework\Phrase
Definition:
Phrase.php:17
$messageFactory
$messageFactory
Definition:
messages.php:10