Skip to content

Commit 871ac64

Browse files
committed
Merge pull request #563 from magento-mpi/sprint70
[MPI] Sprint70
2 parents 56ff40d + 047cea4 commit 871ac64

File tree

106 files changed

+2651
-1232
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+2651
-1232
lines changed

app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/Place.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ public function execute()
119119
} catch (\Magento\Framework\Exception\LocalizedException $e) {
120120
$message = $e->getMessage();
121121
if (!empty($message)) {
122-
$this->messageManager->addError($message);
122+
$this->messageManager->addErrorMessage($message);
123123
}
124124
$isError = true;
125125
} catch (\Exception $e) {
126-
$this->messageManager->addException($e, __('Order saving error: %1', $e->getMessage()));
126+
$this->messageManager->addExceptionMessage($e, __('Order saving error: %1', $e->getMessage()));
127127
$isError = true;
128128
}
129129

app/code/Magento/Braintree/Controller/PayPal/PlaceOrder.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,9 @@ public function execute()
7777
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
7878
return $resultRedirect->setPath('checkout/onepage/success');
7979
} catch (\Magento\Framework\Exception\LocalizedException $e) {
80-
$this->messageManager->addError($e->getMessage());
80+
$this->messageManager->addExceptionMessage($e, $e->getMessage());
8181
} catch (\Exception $e) {
82-
$this->messageManager->addError(__('We can\'t place the order.'));
83-
$this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e);
82+
$this->messageManager->addExceptionMessage($e, __('We can\'t place the order.'));
8483
}
8584
/** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
8685
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);

app/code/Magento/Braintree/Controller/PayPal/Review.php

+4-12
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,6 @@ class Review extends \Magento\Braintree\Controller\PayPal
1717
*/
1818
protected $jsonHelper;
1919

20-
/**
21-
* @param \Magento\Framework\App\Action\Context $context
22-
* @param \Magento\Customer\Model\Session $customerSession
23-
* @param \Magento\Checkout\Model\Session $checkoutSession
24-
* @param \Magento\Braintree\Model\Config\PayPal $braintreePayPalConfig
25-
* @param \Magento\Paypal\Model\Config $paypalConfig
26-
*/
27-
2820
/**
2921
* @param \Magento\Framework\App\Action\Context $context
3022
* @param \Magento\Customer\Model\Session $customerSession
@@ -77,7 +69,7 @@ public function execute()
7769
} else {
7870
$paymentMethod = $this->getQuote()->getPayment()->getMethodInstance();
7971
if (!$paymentMethod || $paymentMethod->getCode() !== PayPal::METHOD_CODE) {
80-
$this->messageManager->addError(
72+
$this->messageManager->addErrorMessage(
8173
__('Incorrect payment method.')
8274
);
8375

@@ -96,12 +88,12 @@ public function execute()
9688
$reviewBlock->getChildBlock('shipping_method')->setQuote($this->getQuote());
9789
return $resultPage;
9890
} catch (\Magento\Framework\Exception\LocalizedException $e) {
99-
$this->messageManager->addError($e->getMessage());
91+
$this->messageManager->addExceptionMessage($e, $e->getMessage());
10092
} catch (\Exception $e) {
101-
$this->messageManager->addError(
93+
$this->messageManager->addExceptionMessage(
94+
$e,
10295
__('We can\'t initialize checkout review.')
10396
);
104-
$this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e);
10597
}
10698

10799
/** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */

app/code/Magento/Braintree/Controller/PayPal/SaveShippingMethod.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ public function execute()
3131
return;
3232
}
3333
} catch (\Magento\Framework\Exception\LocalizedException $e) {
34-
$this->messageManager->addError($e->getMessage());
34+
$this->messageManager->addExceptionMessage($e, $e->getMessage());
3535
} catch (\Exception $e) {
36-
$this->messageManager->addError(__('We can\'t update shipping method.'));
37-
$this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e);
36+
$this->messageManager->addExceptionMessage($e, __('We can\'t update shipping method.'));
3837
}
3938
if ($isAjax) {
4039
$this->getResponse()->setBody(

app/code/Magento/Braintree/Test/Unit/Controller/PayPal/PlaceOrderTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@ public function testExecuteException()
219219
->willThrowException($exception);
220220

221221
$this->messageManager->expects($this->once())
222-
->method('addError')
223-
->with($exceptionMsg);
222+
->method('addExceptionMessage')
223+
->with($exception, $exceptionMsg);
224224

225225
$resultRedirect = $this->getMockBuilder('\Magento\Framework\Controller\Result\Redirect')
226226
->disableOriginalConstructor()

app/code/Magento/Braintree/Test/Unit/Controller/PayPal/ReviewTest.php

+8-7
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ public function testExecuteNoPayment()
314314
->willReturn($paymentMock);
315315

316316
$this->messageManagerMock->expects($this->once())
317-
->method('addError')
317+
->method('addErrorMessage')
318318
->with(new \Magento\Framework\Phrase('Incorrect payment method.'));
319319

320320
$resultRedirect = $this->getMockBuilder('\Magento\Framework\Controller\Result\Redirect')
@@ -338,7 +338,7 @@ public function testExecuteIncorrectPaymentMathod()
338338
->method('getCode')
339339
->willReturn('incorrect_method');
340340
$this->messageManagerMock->expects($this->once())
341-
->method('addError')
341+
->method('addErrorMessage')
342342
->with(new \Magento\Framework\Phrase('Incorrect payment method.'));
343343

344344
$resultRedirect = $this->getMockBuilder('\Magento\Framework\Controller\Result\Redirect')
@@ -380,13 +380,14 @@ public function testExecuteValidationFailure()
380380

381381
$this->setupCart();
382382
$errorMessage = new \Magento\Framework\Phrase('Selected payment type is not allowed for billing country.');
383+
$exception = new \Magento\Framework\Exception\LocalizedException($errorMessage);
383384

384385
$this->paymentMethodInstanceMock->expects($this->once())
385386
->method('validate')
386-
->willThrowException(new \Magento\Framework\Exception\LocalizedException($errorMessage));
387+
->willThrowException($exception);
387388
$this->messageManagerMock->expects($this->once())
388-
->method('addError')
389-
->with(new \Magento\Framework\Phrase('Selected payment type is not allowed for billing country.'));
389+
->method('addExceptionMessage')
390+
->with($exception, $errorMessage);
390391

391392
$resultRedirect = $this->getMockBuilder('\Magento\Framework\Controller\Result\Redirect')
392393
->disableOriginalConstructor()
@@ -427,8 +428,8 @@ public function testExecuteException()
427428
$errorMsg = new \Magento\Framework\Phrase('error');
428429
$exception = new \Magento\Framework\Exception\LocalizedException($errorMsg);
429430
$this->messageManagerMock->expects($this->once())
430-
->method('addError')
431-
->with($errorMsg);
431+
->method('addExceptionMessage')
432+
->with($exception, $errorMsg);
432433

433434
$this->checkoutMock->expects($this->once())
434435
->method('initializeQuoteForReview')

app/code/Magento/Braintree/Test/Unit/Controller/PayPal/SaveShippingMethodTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ public function testExecuteException()
229229
->willThrowException($exception);
230230

231231
$this->messageManager->expects($this->once())
232-
->method('addError')
233-
->with($exceptionMsg);
232+
->method('addExceptionMessage')
233+
->with($exception, $exceptionMsg);
234234

235235
$this->responseMock->expects($this->once())
236236
->method('setBody')

app/code/Magento/Braintree/etc/adminhtml/system.xml

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
<section id="payment">
1111
<group id="braintree_section" translate="label" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
1212
<label>Braintree</label>
13-
<comment><![CDATA[Add Braintree as additional payment method to your checkout page.]]></comment>
13+
<comment><![CDATA[Accept credit/debit cards and PayPal in your Magento store. No setup or monthly fees and your customers never leave your store to complete the purchase.]]></comment>
1414
<attribute type="expanded">1</attribute>
15-
<fieldset_css>complex</fieldset_css>
15+
<fieldset_css>complex braintree-section</fieldset_css>
1616
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Group</frontend_model>
1717
<group id="braintree" translate="label" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
18+
<label><![CDATA[&nbsp;]]></label>
1819
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Payment</frontend_model>
19-
<comment><![CDATA[<a href="https://www.braintreegateway.com/login" target="_blank">Click here to login to your existing Braintree account</a>. Or to setup a new account and accept payments on your website, <a href="https://apply.braintreegateway.com/signup/us" target="_blank">click here to signup for a Braintree account</a>.]]></comment>
2020
<attribute type="activity_path">payment/braintree/active</attribute>
2121
<field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0">
2222
<label>Enabled Braintree</label>
@@ -35,6 +35,7 @@
3535
</requires>
3636
</field>
3737
<group id="braintree_required" translate="label" showInDefault="1" showInWebsite="1" sortOrder="5">
38+
<comment><![CDATA[<a href="https://www.braintreegateway.com/login" target="_blank">Click here to login to your existing Braintree account</a>. Or to setup a new account and accept payments on your website, <a href="https://apply.braintreegateway.com/signup/us" target="_blank">click here to signup for a Braintree account</a>.]]></comment>
3839
<label>Basic Braintree Settings</label>
3940
<attribute type="expanded">1</attribute>
4041
<frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © 2015 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
9+
<head>
10+
<css src="Magento_Braintree::styles.css"/>
11+
</head>
12+
</page>
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* Copyright © 2015 Magento. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
.braintree-section .entry-edit-head > .config-heading .heading strong {padding-left:150px;background:url(images/braintree_logo.png) no-repeat 0 0 / 145px auto;line-height:36px;}
7+
.braintree-section .entry-edit-head > .config-heading:before {background: url("images/braintree_allinone.png") no-repeat 0 0 / 100% auto;content: "";display: inline;float: right;height: 35px;width: 280px;}

app/code/Magento/Braintree/view/frontend/layout/braintree_paypal_review.xml

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
*/
77
-->
88
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
9+
<head>
10+
<title>Review Order</title>
11+
</head>
912
<update handle="checkout_onepage_review_item_renderers"/>
1013
<body>
1114
<referenceBlock name="head.components">

app/code/Magento/Bundle/Block/Checkout/Cart/Item/Renderer.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use Magento\Bundle\Helper\Catalog\Product\Configuration;
99
use Magento\Framework\Pricing\PriceCurrencyInterface;
10+
use Magento\Framework\View\Element\Message\InterpretationStrategyInterface;
1011

1112
/**
1213
* Shopping cart item render block
@@ -26,11 +27,12 @@ class Renderer extends \Magento\Checkout\Block\Cart\Item\Renderer
2627
* @param \Magento\Framework\View\Element\Template\Context $context
2728
* @param \Magento\Catalog\Helper\Product\Configuration $productConfig
2829
* @param \Magento\Checkout\Model\Session $checkoutSession
29-
* @param \Magento\Catalog\Helper\Image $imageBuilder
30+
* @param \Magento\Catalog\Block\Product\ImageBuilder|\Magento\Catalog\Helper\Image $imageBuilder
3031
* @param \Magento\Framework\Url\Helper\Data $urlHelper
3132
* @param \Magento\Framework\Message\ManagerInterface $messageManager
3233
* @param PriceCurrencyInterface $priceCurrency
3334
* @param \Magento\Framework\Module\Manager $moduleManager
35+
* @param InterpretationStrategyInterface $messageInterpretationStrategy
3436
* @param Configuration $bundleProductConfiguration
3537
* @param array $data
3638
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
@@ -44,6 +46,7 @@ public function __construct(
4446
\Magento\Framework\Message\ManagerInterface $messageManager,
4547
PriceCurrencyInterface $priceCurrency,
4648
\Magento\Framework\Module\Manager $moduleManager,
49+
InterpretationStrategyInterface $messageInterpretationStrategy,
4750
Configuration $bundleProductConfiguration,
4851
array $data = []
4952
) {
@@ -57,6 +60,7 @@ public function __construct(
5760
$messageManager,
5861
$priceCurrency,
5962
$moduleManager,
63+
$messageInterpretationStrategy,
6064
$data
6165
);
6266
$this->_isScopePrivate = true;

app/code/Magento/Checkout/Block/Cart/Item/Renderer.php

+14-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Magento\Checkout\Block\Cart\Item\Renderer\Actions;
99
use Magento\Framework\Pricing\PriceCurrencyInterface;
1010
use Magento\Framework\View\Element\AbstractBlock;
11+
use Magento\Framework\View\Element\Message\InterpretationStrategyInterface;
1112
use Magento\Quote\Model\Quote\Item\AbstractItem;
1213
use Magento\Catalog\Pricing\Price\ConfiguredPriceInterface;
1314

@@ -84,6 +85,11 @@ class Renderer extends \Magento\Framework\View\Element\Template implements
8485
*/
8586
public $moduleManager;
8687

88+
/**
89+
* @var InterpretationStrategyInterface
90+
*/
91+
private $messageInterpretationStrategy;
92+
8793
/**
8894
* @param \Magento\Framework\View\Element\Template\Context $context
8995
* @param \Magento\Catalog\Helper\Product\Configuration $productConfig
@@ -93,7 +99,9 @@ class Renderer extends \Magento\Framework\View\Element\Template implements
9399
* @param \Magento\Framework\Message\ManagerInterface $messageManager
94100
* @param PriceCurrencyInterface $priceCurrency
95101
* @param \Magento\Framework\Module\Manager $moduleManager
102+
* @param InterpretationStrategyInterface $messageInterpretationStrategy
96103
* @param array $data
104+
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
97105
*/
98106
public function __construct(
99107
\Magento\Framework\View\Element\Template\Context $context,
@@ -104,6 +112,7 @@ public function __construct(
104112
\Magento\Framework\Message\ManagerInterface $messageManager,
105113
PriceCurrencyInterface $priceCurrency,
106114
\Magento\Framework\Module\Manager $moduleManager,
115+
InterpretationStrategyInterface $messageInterpretationStrategy,
107116
array $data = []
108117
) {
109118
$this->priceCurrency = $priceCurrency;
@@ -115,6 +124,7 @@ public function __construct(
115124
parent::__construct($context, $data);
116125
$this->_isScopePrivate = true;
117126
$this->moduleManager = $moduleManager;
127+
$this->messageInterpretationStrategy = $messageInterpretationStrategy;
118128
}
119129

120130
/**
@@ -312,7 +322,10 @@ public function getMessages()
312322
$additionalMessages = $collection->getItems();
313323
foreach ($additionalMessages as $message) {
314324
/* @var $message \Magento\Framework\Message\MessageInterface */
315-
$messages[] = ['text' => $message->getText(), 'type' => $message->getType()];
325+
$messages[] = [
326+
'text' => $this->messageInterpretationStrategy->interpret($message),
327+
'type' => $message->getType()
328+
];
316329
}
317330
}
318331
$this->messageManager->getMessages('quote_item' . $quoteItem->getId())->clear();

app/code/Magento/Checkout/Block/Cart/ValidationMessages.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Checkout\Block\Cart;
77

8+
use Magento\Framework\View\Element\Message\InterpretationStrategyInterface;
9+
810
/**
911
* Shopping cart validation messages block
1012
*/
@@ -21,6 +23,7 @@ class ValidationMessages extends \Magento\Framework\View\Element\Messages
2123
* @param \Magento\Framework\Message\Factory $messageFactory
2224
* @param \Magento\Framework\Message\CollectionFactory $collectionFactory
2325
* @param \Magento\Framework\Message\ManagerInterface $messageManager
26+
* @param InterpretationStrategyInterface $interpretationStrategy
2427
* @param \Magento\Checkout\Helper\Cart $cartHelper
2528
* @param \Magento\Framework\Locale\CurrencyInterface $currency
2629
* @param array $data
@@ -30,6 +33,7 @@ public function __construct(
3033
\Magento\Framework\Message\Factory $messageFactory,
3134
\Magento\Framework\Message\CollectionFactory $collectionFactory,
3235
\Magento\Framework\Message\ManagerInterface $messageManager,
36+
InterpretationStrategyInterface $interpretationStrategy,
3337
\Magento\Checkout\Helper\Cart $cartHelper,
3438
\Magento\Framework\Locale\CurrencyInterface $currency,
3539
array $data = []
@@ -39,6 +43,7 @@ public function __construct(
3943
$messageFactory,
4044
$collectionFactory,
4145
$messageManager,
46+
$interpretationStrategy,
4247
$data
4348
);
4449
$this->cartHelper = $cartHelper;
@@ -101,6 +106,9 @@ protected function addQuoteMessages()
101106
$messages[] = $message;
102107
}
103108
}
104-
$this->messageManager->addUniqueMessages($messages);
109+
110+
if ($messages) {
111+
$this->messageManager->addUniqueMessages($messages);
112+
}
105113
}
106114
}

app/code/Magento/Checkout/Controller/Cart/Add.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ public function execute()
114114
if (!$this->cart->getQuote()->getHasError()) {
115115
$message = __(
116116
'You added %1 to your shopping cart.',
117-
$this->_objectManager->get('Magento\Framework\Escaper')->escapeHtml($product->getName())
117+
$product->getName()
118118
);
119-
$this->messageManager->addSuccess($message);
119+
$this->messageManager->addSuccessMessage($message);
120120
}
121121
return $this->goBack(null, $product);
122122
}

app/code/Magento/Downloadable/Block/Checkout/Cart/Item/Renderer.php

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Magento\Downloadable\Block\Checkout\Cart\Item;
1313

1414
use Magento\Framework\Pricing\PriceCurrencyInterface;
15+
use Magento\Framework\View\Element\Message\InterpretationStrategyInterface;
1516

1617
class Renderer extends \Magento\Checkout\Block\Cart\Item\Renderer
1718
{
@@ -31,6 +32,7 @@ class Renderer extends \Magento\Checkout\Block\Cart\Item\Renderer
3132
* @param \Magento\Framework\Message\ManagerInterface $messageManager
3233
* @param PriceCurrencyInterface $priceCurrency
3334
* @param \Magento\Framework\Module\Manager $moduleManager
35+
* @param InterpretationStrategyInterface $messageInterpretationStrategy
3436
* @param \Magento\Downloadable\Helper\Catalog\Product\Configuration $downloadableProductConfiguration
3537
* @param array $data
3638
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
@@ -44,6 +46,7 @@ public function __construct(
4446
\Magento\Framework\Message\ManagerInterface $messageManager,
4547
PriceCurrencyInterface $priceCurrency,
4648
\Magento\Framework\Module\Manager $moduleManager,
49+
InterpretationStrategyInterface $messageInterpretationStrategy,
4750
\Magento\Downloadable\Helper\Catalog\Product\Configuration $downloadableProductConfiguration,
4851
array $data = []
4952
) {
@@ -57,6 +60,7 @@ public function __construct(
5760
$messageManager,
5861
$priceCurrency,
5962
$moduleManager,
63+
$messageInterpretationStrategy,
6064
$data
6165
);
6266
}

0 commit comments

Comments
 (0)