Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Design.php
Go to the documentation of this file.
1 <?php
7 
9 
10 class Design
11 {
15  protected $_designLoader;
16 
20  protected $messageManager;
21 
26  public function __construct(
27  \Magento\Framework\View\DesignLoader $designLoader,
28  \Magento\Framework\Message\ManagerInterface $messageManager
29  ) {
30  $this->_designLoader = $designLoader;
31  $this->messageManager = $messageManager;
32  }
33 
43  public function beforeDispatch(
44  \Magento\Framework\App\ActionInterface $subject,
46  ) {
47  try {
48  $this->_designLoader->load();
49  } catch (\Magento\Framework\Exception\LocalizedException $e) {
50  if ($e->getPrevious() instanceof \Magento\Framework\Config\Dom\ValidationException) {
52  $message = $this->messageManager
53  ->createMessage(MessageInterface::TYPE_ERROR)
54  ->setText($e->getMessage());
55  $this->messageManager->addUniqueMessages([$message]);
56  }
57  }
58  }
59 }
$message
__construct(\Magento\Framework\View\DesignLoader $designLoader, \Magento\Framework\Message\ManagerInterface $messageManager)
Definition: Design.php:26