Skip to content

Commit

Permalink
Merge pull request #563 from magento-mpi/sprint70
Browse files Browse the repository at this point in the history
[MPI] Sprint70
  • Loading branch information
dkvashninbay committed Sep 3, 2015
2 parents 56ff40d + 047cea4 commit 871ac64
Show file tree
Hide file tree
Showing 106 changed files with 2,651 additions and 1,232 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ public function execute()
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$message = $e->getMessage();
if (!empty($message)) {
$this->messageManager->addError($message);
$this->messageManager->addErrorMessage($message);
}
$isError = true;
} catch (\Exception $e) {
$this->messageManager->addException($e, __('Order saving error: %1', $e->getMessage()));
$this->messageManager->addExceptionMessage($e, __('Order saving error: %1', $e->getMessage()));
$isError = true;
}

Expand Down
5 changes: 2 additions & 3 deletions app/code/Magento/Braintree/Controller/PayPal/PlaceOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,9 @@ public function execute()
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
return $resultRedirect->setPath('checkout/onepage/success');
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->messageManager->addError($e->getMessage());
$this->messageManager->addExceptionMessage($e, $e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addError(__('We can\'t place the order.'));
$this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e);
$this->messageManager->addExceptionMessage($e, __('We can\'t place the order.'));
}
/** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
Expand Down
16 changes: 4 additions & 12 deletions app/code/Magento/Braintree/Controller/PayPal/Review.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@ class Review extends \Magento\Braintree\Controller\PayPal
*/
protected $jsonHelper;

/**
* @param \Magento\Framework\App\Action\Context $context
* @param \Magento\Customer\Model\Session $customerSession
* @param \Magento\Checkout\Model\Session $checkoutSession
* @param \Magento\Braintree\Model\Config\PayPal $braintreePayPalConfig
* @param \Magento\Paypal\Model\Config $paypalConfig
*/

/**
* @param \Magento\Framework\App\Action\Context $context
* @param \Magento\Customer\Model\Session $customerSession
Expand Down Expand Up @@ -77,7 +69,7 @@ public function execute()
} else {
$paymentMethod = $this->getQuote()->getPayment()->getMethodInstance();
if (!$paymentMethod || $paymentMethod->getCode() !== PayPal::METHOD_CODE) {
$this->messageManager->addError(
$this->messageManager->addErrorMessage(
__('Incorrect payment method.')
);

Expand All @@ -96,12 +88,12 @@ public function execute()
$reviewBlock->getChildBlock('shipping_method')->setQuote($this->getQuote());
return $resultPage;
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->messageManager->addError($e->getMessage());
$this->messageManager->addExceptionMessage($e, $e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addError(
$this->messageManager->addExceptionMessage(
$e,
__('We can\'t initialize checkout review.')
);
$this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e);
}

/** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ public function execute()
return;
}
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->messageManager->addError($e->getMessage());
$this->messageManager->addExceptionMessage($e, $e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addError(__('We can\'t update shipping method.'));
$this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e);
$this->messageManager->addExceptionMessage($e, __('We can\'t update shipping method.'));
}
if ($isAjax) {
$this->getResponse()->setBody(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ public function testExecuteException()
->willThrowException($exception);

$this->messageManager->expects($this->once())
->method('addError')
->with($exceptionMsg);
->method('addExceptionMessage')
->with($exception, $exceptionMsg);

$resultRedirect = $this->getMockBuilder('\Magento\Framework\Controller\Result\Redirect')
->disableOriginalConstructor()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ public function testExecuteNoPayment()
->willReturn($paymentMock);

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

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

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

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

$this->paymentMethodInstanceMock->expects($this->once())
->method('validate')
->willThrowException(new \Magento\Framework\Exception\LocalizedException($errorMessage));
->willThrowException($exception);
$this->messageManagerMock->expects($this->once())
->method('addError')
->with(new \Magento\Framework\Phrase('Selected payment type is not allowed for billing country.'));
->method('addExceptionMessage')
->with($exception, $errorMessage);

$resultRedirect = $this->getMockBuilder('\Magento\Framework\Controller\Result\Redirect')
->disableOriginalConstructor()
Expand Down Expand Up @@ -427,8 +428,8 @@ public function testExecuteException()
$errorMsg = new \Magento\Framework\Phrase('error');
$exception = new \Magento\Framework\Exception\LocalizedException($errorMsg);
$this->messageManagerMock->expects($this->once())
->method('addError')
->with($errorMsg);
->method('addExceptionMessage')
->with($exception, $errorMsg);

$this->checkoutMock->expects($this->once())
->method('initializeQuoteForReview')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ public function testExecuteException()
->willThrowException($exception);

$this->messageManager->expects($this->once())
->method('addError')
->with($exceptionMsg);
->method('addExceptionMessage')
->with($exception, $exceptionMsg);

$this->responseMock->expects($this->once())
->method('setBody')
Expand Down
7 changes: 4 additions & 3 deletions app/code/Magento/Braintree/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
<section id="payment">
<group id="braintree_section" translate="label" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Braintree</label>
<comment><![CDATA[Add Braintree as additional payment method to your checkout page.]]></comment>
<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>
<attribute type="expanded">1</attribute>
<fieldset_css>complex</fieldset_css>
<fieldset_css>complex braintree-section</fieldset_css>
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Group</frontend_model>
<group id="braintree" translate="label" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
<label><![CDATA[&nbsp;]]></label>
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Payment</frontend_model>
<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>
<attribute type="activity_path">payment/braintree/active</attribute>
<field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Enabled Braintree</label>
Expand All @@ -35,6 +35,7 @@
</requires>
</field>
<group id="braintree_required" translate="label" showInDefault="1" showInWebsite="1" sortOrder="5">
<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>
<label>Basic Braintree Settings</label>
<attribute type="expanded">1</attribute>
<frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<head>
<css src="Magento_Braintree::styles.css"/>
</head>
</page>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions app/code/Magento/Braintree/view/adminhtml/web/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

.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;}
.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;}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<head>
<title>Review Order</title>
</head>
<update handle="checkout_onepage_review_item_renderers"/>
<body>
<referenceBlock name="head.components">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

use Magento\Bundle\Helper\Catalog\Product\Configuration;
use Magento\Framework\Pricing\PriceCurrencyInterface;
use Magento\Framework\View\Element\Message\InterpretationStrategyInterface;

/**
* Shopping cart item render block
Expand All @@ -26,11 +27,12 @@ class Renderer extends \Magento\Checkout\Block\Cart\Item\Renderer
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Catalog\Helper\Product\Configuration $productConfig
* @param \Magento\Checkout\Model\Session $checkoutSession
* @param \Magento\Catalog\Helper\Image $imageBuilder
* @param \Magento\Catalog\Block\Product\ImageBuilder|\Magento\Catalog\Helper\Image $imageBuilder
* @param \Magento\Framework\Url\Helper\Data $urlHelper
* @param \Magento\Framework\Message\ManagerInterface $messageManager
* @param PriceCurrencyInterface $priceCurrency
* @param \Magento\Framework\Module\Manager $moduleManager
* @param InterpretationStrategyInterface $messageInterpretationStrategy
* @param Configuration $bundleProductConfiguration
* @param array $data
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
Expand All @@ -44,6 +46,7 @@ public function __construct(
\Magento\Framework\Message\ManagerInterface $messageManager,
PriceCurrencyInterface $priceCurrency,
\Magento\Framework\Module\Manager $moduleManager,
InterpretationStrategyInterface $messageInterpretationStrategy,
Configuration $bundleProductConfiguration,
array $data = []
) {
Expand All @@ -57,6 +60,7 @@ public function __construct(
$messageManager,
$priceCurrency,
$moduleManager,
$messageInterpretationStrategy,
$data
);
$this->_isScopePrivate = true;
Expand Down
15 changes: 14 additions & 1 deletion app/code/Magento/Checkout/Block/Cart/Item/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Magento\Checkout\Block\Cart\Item\Renderer\Actions;
use Magento\Framework\Pricing\PriceCurrencyInterface;
use Magento\Framework\View\Element\AbstractBlock;
use Magento\Framework\View\Element\Message\InterpretationStrategyInterface;
use Magento\Quote\Model\Quote\Item\AbstractItem;
use Magento\Catalog\Pricing\Price\ConfiguredPriceInterface;

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

/**
* @var InterpretationStrategyInterface
*/
private $messageInterpretationStrategy;

/**
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Catalog\Helper\Product\Configuration $productConfig
Expand All @@ -93,7 +99,9 @@ class Renderer extends \Magento\Framework\View\Element\Template implements
* @param \Magento\Framework\Message\ManagerInterface $messageManager
* @param PriceCurrencyInterface $priceCurrency
* @param \Magento\Framework\Module\Manager $moduleManager
* @param InterpretationStrategyInterface $messageInterpretationStrategy
* @param array $data
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
Expand All @@ -104,6 +112,7 @@ public function __construct(
\Magento\Framework\Message\ManagerInterface $messageManager,
PriceCurrencyInterface $priceCurrency,
\Magento\Framework\Module\Manager $moduleManager,
InterpretationStrategyInterface $messageInterpretationStrategy,
array $data = []
) {
$this->priceCurrency = $priceCurrency;
Expand All @@ -115,6 +124,7 @@ public function __construct(
parent::__construct($context, $data);
$this->_isScopePrivate = true;
$this->moduleManager = $moduleManager;
$this->messageInterpretationStrategy = $messageInterpretationStrategy;
}

/**
Expand Down Expand Up @@ -312,7 +322,10 @@ public function getMessages()
$additionalMessages = $collection->getItems();
foreach ($additionalMessages as $message) {
/* @var $message \Magento\Framework\Message\MessageInterface */
$messages[] = ['text' => $message->getText(), 'type' => $message->getType()];
$messages[] = [
'text' => $this->messageInterpretationStrategy->interpret($message),
'type' => $message->getType()
];
}
}
$this->messageManager->getMessages('quote_item' . $quoteItem->getId())->clear();
Expand Down
10 changes: 9 additions & 1 deletion app/code/Magento/Checkout/Block/Cart/ValidationMessages.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/
namespace Magento\Checkout\Block\Cart;

use Magento\Framework\View\Element\Message\InterpretationStrategyInterface;

/**
* Shopping cart validation messages block
*/
Expand All @@ -21,6 +23,7 @@ class ValidationMessages extends \Magento\Framework\View\Element\Messages
* @param \Magento\Framework\Message\Factory $messageFactory
* @param \Magento\Framework\Message\CollectionFactory $collectionFactory
* @param \Magento\Framework\Message\ManagerInterface $messageManager
* @param InterpretationStrategyInterface $interpretationStrategy
* @param \Magento\Checkout\Helper\Cart $cartHelper
* @param \Magento\Framework\Locale\CurrencyInterface $currency
* @param array $data
Expand All @@ -30,6 +33,7 @@ public function __construct(
\Magento\Framework\Message\Factory $messageFactory,
\Magento\Framework\Message\CollectionFactory $collectionFactory,
\Magento\Framework\Message\ManagerInterface $messageManager,
InterpretationStrategyInterface $interpretationStrategy,
\Magento\Checkout\Helper\Cart $cartHelper,
\Magento\Framework\Locale\CurrencyInterface $currency,
array $data = []
Expand All @@ -39,6 +43,7 @@ public function __construct(
$messageFactory,
$collectionFactory,
$messageManager,
$interpretationStrategy,
$data
);
$this->cartHelper = $cartHelper;
Expand Down Expand Up @@ -101,6 +106,9 @@ protected function addQuoteMessages()
$messages[] = $message;
}
}
$this->messageManager->addUniqueMessages($messages);

if ($messages) {
$this->messageManager->addUniqueMessages($messages);
}
}
}
4 changes: 2 additions & 2 deletions app/code/Magento/Checkout/Controller/Cart/Add.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ public function execute()
if (!$this->cart->getQuote()->getHasError()) {
$message = __(
'You added %1 to your shopping cart.',
$this->_objectManager->get('Magento\Framework\Escaper')->escapeHtml($product->getName())
$product->getName()
);
$this->messageManager->addSuccess($message);
$this->messageManager->addSuccessMessage($message);
}
return $this->goBack(null, $product);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Magento\Downloadable\Block\Checkout\Cart\Item;

use Magento\Framework\Pricing\PriceCurrencyInterface;
use Magento\Framework\View\Element\Message\InterpretationStrategyInterface;

class Renderer extends \Magento\Checkout\Block\Cart\Item\Renderer
{
Expand All @@ -31,6 +32,7 @@ class Renderer extends \Magento\Checkout\Block\Cart\Item\Renderer
* @param \Magento\Framework\Message\ManagerInterface $messageManager
* @param PriceCurrencyInterface $priceCurrency
* @param \Magento\Framework\Module\Manager $moduleManager
* @param InterpretationStrategyInterface $messageInterpretationStrategy
* @param \Magento\Downloadable\Helper\Catalog\Product\Configuration $downloadableProductConfiguration
* @param array $data
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
Expand All @@ -44,6 +46,7 @@ public function __construct(
\Magento\Framework\Message\ManagerInterface $messageManager,
PriceCurrencyInterface $priceCurrency,
\Magento\Framework\Module\Manager $moduleManager,
InterpretationStrategyInterface $messageInterpretationStrategy,
\Magento\Downloadable\Helper\Catalog\Product\Configuration $downloadableProductConfiguration,
array $data = []
) {
Expand All @@ -57,6 +60,7 @@ public function __construct(
$messageManager,
$priceCurrency,
$moduleManager,
$messageInterpretationStrategy,
$data
);
}
Expand Down
Loading

0 comments on commit 871ac64

Please sign in to comment.