mirror of
https://github.com/bdnugget/magento2.git
synced 2026-11-07 09:17:35 +00:00
51 lines
1.5 KiB
PHP
51 lines
1.5 KiB
PHP
<?php
|
|
/**
|
|
* Copyright © Magento, Inc. All rights reserved.
|
|
* See COPYING.txt for license details.
|
|
*/
|
|
namespace Magento\Checkout\Observer;
|
|
|
|
use Magento\Framework\Event\ObserverInterface;
|
|
|
|
class LoadCustomerQuoteObserver implements ObserverInterface
|
|
{
|
|
/**
|
|
* @var \Magento\Checkout\Model\Session
|
|
*/
|
|
protected $checkoutSession;
|
|
|
|
/**
|
|
* @var \Magento\Framework\Message\ManagerInterface
|
|
*/
|
|
protected $messageManager;
|
|
|
|
/**
|
|
* @param \Magento\Checkout\Model\Session $checkoutSession
|
|
* @param \Magento\Framework\Message\ManagerInterface $messageManager
|
|
* @codeCoverageIgnore
|
|
*/
|
|
public function __construct(
|
|
\Magento\Checkout\Model\Session $checkoutSession,
|
|
\Magento\Framework\Message\ManagerInterface $messageManager
|
|
) {
|
|
$this->checkoutSession = $checkoutSession;
|
|
$this->messageManager = $messageManager;
|
|
}
|
|
|
|
/**
|
|
* @param \Magento\Framework\Event\Observer $observer
|
|
* @return void
|
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
|
*/
|
|
public function execute(\Magento\Framework\Event\Observer $observer)
|
|
{
|
|
try {
|
|
$this->checkoutSession->loadCustomerQuote();
|
|
} catch (\Magento\Framework\Exception\LocalizedException $e) {
|
|
$this->messageManager->addErrorMessage($e->getMessage());
|
|
} catch (\Exception $e) {
|
|
$this->messageManager->addExceptionMessage($e, __('Load customer quote error'));
|
|
}
|
|
}
|
|
}
|