Skip to content

Commit c9bfc13

Browse files
author
rossbrandon
committed
Merge remote-tracking branch 'origin/MAGETWO-83013-ReleaseNotification' into MAGETWO-83013-ReleaseNotification
2 parents 2375a49 + 2e57e34 commit c9bfc13

File tree

136 files changed

+5305
-178
lines changed

Some content is hidden

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

136 files changed

+5305
-178
lines changed

app/code/Magento/Backend/view/adminhtml/templates/admin/access_denied.phtml

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,22 @@
1212
* @see \Magento\Backend\Block\Denied
1313
*/
1414
?>
15-
<h1 class="page-heading"><?= /* @escapeNotVerified */ __('Access denied') ?></h1>
16-
<?php if (!$block->hasAvailableResources()): ?>
17-
<p>
18-
<?= /* @escapeNotVerified */ __('Please try to sign out and sign in again.') ?><br/>
19-
<?= /* @escapeNotVerified */ __('If you continue to receive this message, please contact the store owner.') ?>
20-
</p>
21-
<?php else: ?>
22-
<p><?= /* @escapeNotVerified */ __('You need more permissions to access this.') ?></p>
23-
<?php endif?>
15+
<hr class="access-denied-hr"/>
16+
<div class="access-denied-page">
17+
<h2 class="page-heading"><?= $block->escapeHtml(__('Sorry, you need permissions to view this content.')) ?></h2>
18+
<?php if (!$block->hasAvailableResources()): ?>
19+
<strong><?= $block->escapeHtml(__('Next steps')) ?></strong>
20+
<ul>
21+
<li><span><?= $block->escapeHtml(__('If you think this is an error, try signing out and signing in again.')) ?></span></li>
22+
<li><span><?= $block->escapeHtml(__('Contact a system administrator or store owner to gain permissions.')) ?></span></li>
23+
<li>
24+
<span><?= $block->escapeHtml(__('Return to ')) ?>
25+
<a href="<?= $block->escapeHtmlAttr(__('javascript:history.back()')) ?>">
26+
<?= $block->escapeHtml(__('previous page')) ?></a><?= $block->escapeHtml(__('.')) ?>
27+
</span>
28+
</li>
29+
</ul>
30+
<?php else: ?>
31+
<p><?= $block->escapeHtml(__('Access denied.')) ?></p>
32+
<?php endif?>
33+
</div>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Braintree\Model\InstantPurchase\CreditCard;
7+
8+
use Magento\Braintree\Gateway\Config\Config;
9+
use Magento\InstantPurchase\PaymentMethodIntegration\AvailabilityCheckerInterface;
10+
11+
/**
12+
* Availability of Braintree vaults for instant purchase.
13+
*/
14+
class AvailabilityChecker implements AvailabilityCheckerInterface
15+
{
16+
/**
17+
* @var Config
18+
*/
19+
private $config;
20+
21+
/**
22+
* AvailabilityChecker constructor.
23+
* @param Config $config
24+
*/
25+
public function __construct(Config $config)
26+
{
27+
$this->config = $config;
28+
}
29+
30+
/**
31+
* @inheritdoc
32+
*/
33+
public function isAvailable(): bool
34+
{
35+
if ($this->config->isVerify3DSecure()) {
36+
// Support of 3D secure not implemented for instant purchase yet.
37+
return false;
38+
}
39+
40+
return true;
41+
}
42+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Braintree\Model\InstantPurchase\CreditCard;
7+
8+
use Magento\InstantPurchase\PaymentMethodIntegration\PaymentTokenFormatterInterface;
9+
use Magento\Vault\Api\Data\PaymentTokenInterface;
10+
11+
/**
12+
* Braintree stored credit card formatter.
13+
*/
14+
class TokenFormatter implements PaymentTokenFormatterInterface
15+
{
16+
/**
17+
* Most used credit card types
18+
* @var array
19+
*/
20+
public static $baseCardTypes = [
21+
'AE' => 'American Express',
22+
'VI' => 'Visa',
23+
'MC' => 'MasterCard',
24+
'DI' => 'Discover',
25+
'JBC' => 'JBC',
26+
'CUP' => 'China Union Pay',
27+
'MI' => 'Maestro',
28+
];
29+
30+
/**
31+
* @inheritdoc
32+
*/
33+
public function formatPaymentToken(PaymentTokenInterface $paymentToken): string
34+
{
35+
$details = json_decode($paymentToken->getTokenDetails() ?: '{}', true);
36+
if (!isset($details['type'], $details['maskedCC'], $details['expirationDate'])) {
37+
throw new \InvalidArgumentException('Invalid Braintree credit card token details.');
38+
}
39+
40+
if (isset(self::$baseCardTypes[$details['type']])) {
41+
$ccType = self::$baseCardTypes[$details['type']];
42+
} else {
43+
$ccType = $details['type'];
44+
}
45+
46+
$formatted = sprintf(
47+
'%s: %s, %s: %s (%s: %s)',
48+
__('Credit Card'),
49+
$ccType,
50+
__('ending'),
51+
$details['maskedCC'],
52+
__('expires'),
53+
$details['expirationDate']
54+
);
55+
56+
return $formatted;
57+
}
58+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Braintree\Model\InstantPurchase\PayPal;
7+
8+
use Magento\InstantPurchase\PaymentMethodIntegration\PaymentTokenFormatterInterface;
9+
use Magento\Vault\Api\Data\PaymentTokenInterface;
10+
11+
/**
12+
* Braintree PayPal token formatter.
13+
*/
14+
class TokenFormatter implements PaymentTokenFormatterInterface
15+
{
16+
/**
17+
* @inheritdoc
18+
*/
19+
public function formatPaymentToken(PaymentTokenInterface $paymentToken): string
20+
{
21+
$details = json_decode($paymentToken->getTokenDetails() ?: '{}', true);
22+
if (!isset($details['payerEmail'])) {
23+
throw new \InvalidArgumentException('Invalid Braintree PayPal token details.');
24+
}
25+
26+
$formatted = sprintf(
27+
'%s: %s',
28+
__('PayPal'),
29+
$details['payerEmail']
30+
);
31+
32+
return $formatted;
33+
}
34+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Braintree\Model\InstantPurchase;
7+
8+
use Magento\Braintree\Gateway\Command\GetPaymentNonceCommand;
9+
use Magento\InstantPurchase\PaymentMethodIntegration\PaymentAdditionalInformationProviderInterface;
10+
use Magento\Vault\Api\Data\PaymentTokenInterface;
11+
12+
/**
13+
* Provides Braintree specific payment additional information for instant purchase.
14+
*/
15+
class PaymentAdditionalInformationProvider implements PaymentAdditionalInformationProviderInterface
16+
{
17+
/**
18+
* @var GetPaymentNonceCommand
19+
*/
20+
private $getPaymentNonceCommand;
21+
22+
/**
23+
* PaymentAdditionalInformationProvider constructor.
24+
* @param GetPaymentNonceCommand $getPaymentNonceCommand
25+
*/
26+
public function __construct(GetPaymentNonceCommand $getPaymentNonceCommand)
27+
{
28+
$this->getPaymentNonceCommand = $getPaymentNonceCommand;
29+
}
30+
31+
/**
32+
* @inheritdoc
33+
*/
34+
public function getAdditionalInformation(PaymentTokenInterface $paymentToken): array
35+
{
36+
$paymentMethodNonce = $this->getPaymentNonceCommand->execute([
37+
PaymentTokenInterface::CUSTOMER_ID => $paymentToken->getCustomerId(),
38+
PaymentTokenInterface::PUBLIC_HASH => $paymentToken->getPublicHash(),
39+
])->get()['paymentMethodNonce'];
40+
41+
return [
42+
'payment_method_nonce' => $paymentMethodNonce,
43+
];
44+
}
45+
}

app/code/Magento/Braintree/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"magento/module-sales": "101.0.*",
1313
"magento/module-backend": "100.2.*",
1414
"magento/module-vault": "101.0.*",
15+
"magento/module-instant-purchase": "100.2.*",
1516
"magento/module-customer": "101.0.*",
1617
"magento/module-catalog": "102.0.*",
1718
"magento/module-quote": "101.0.*",

app/code/Magento/Braintree/etc/config.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,20 @@
7171
<braintree_cc_vault>
7272
<model>BraintreeCreditCardVaultFacade</model>
7373
<title>Stored Cards (Braintree)</title>
74+
<instant_purchase>
75+
<available>Magento\Braintree\Model\InstantPurchase\CreditCard\AvailabilityChecker</available>
76+
<tokenFormat>Magento\Braintree\Model\InstantPurchase\CreditCard\TokenFormatter</tokenFormat>
77+
<additionalInformation>Magento\Braintree\Model\InstantPurchase\PaymentAdditionalInformationProvider</additionalInformation>
78+
</instant_purchase>
7479
</braintree_cc_vault>
7580
<braintree_paypal_vault>
7681
<model>BraintreePayPalVaultFacade</model>
7782
<title>Stored Accounts (Braintree PayPal)</title>
7883
<can_use_internal>1</can_use_internal>
84+
<instant_purchase>
85+
<tokenFormat>Magento\Braintree\Model\InstantPurchase\PayPal\TokenFormatter</tokenFormat>
86+
<additionalInformation>Magento\Braintree\Model\InstantPurchase\PaymentAdditionalInformationProvider</additionalInformation>
87+
</instant_purchase>
7988
</braintree_paypal_vault>
8089
</payment>
8190
</default>

app/code/Magento/Catalog/Model/ImageExtractor.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
*/
66
namespace Magento\Catalog\Model;
77

8-
use Magento\Catalog\Model\Product\Attribute\Backend\Media\ImageEntryConverter;
98
use Magento\Catalog\Helper\Image;
9+
use Magento\Catalog\Model\Product\Attribute\Backend\Media\ImageEntryConverter;
10+
use Magento\Framework\View\Xsd\Media\TypeDataExtractorInterface;
1011

11-
class ImageExtractor implements \Magento\Framework\View\Xsd\Media\TypeDataExtractorInterface
12+
class ImageExtractor implements TypeDataExtractorInterface
1213
{
1314
/**
1415
* Extract configuration data of images from the DOM structure
@@ -30,8 +31,11 @@ public function process(\DOMElement $mediaNode, $mediaParentTag)
3031
if ($attribute->nodeType != XML_ELEMENT_NODE) {
3132
continue;
3233
}
33-
if ($attribute->tagName == 'background') {
34+
$attributeTagName = $attribute->tagName;
35+
if ($attributeTagName === 'background') {
3436
$nodeValue = $this->processImageBackground($attribute->nodeValue);
37+
} elseif ($attributeTagName === 'width' || $attributeTagName === 'height') {
38+
$nodeValue = intval($attribute->nodeValue);
3539
} else {
3640
$nodeValue = $attribute->nodeValue;
3741
}
@@ -55,6 +59,7 @@ private function processImageBackground($backgroundString)
5559
$backgroundArray = [];
5660
if (preg_match($pattern, $backgroundString, $backgroundArray)) {
5761
array_shift($backgroundArray);
62+
$backgroundArray = array_map('intval', $backgroundArray);
5863
}
5964
return $backgroundArray;
6065
}

app/code/Magento/Catalog/Model/Product/Attribute/OptionManagement.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@ public function getItems($attributeCode)
4040
*/
4141
public function add($attributeCode, $option)
4242
{
43+
/** @var \Magento\Eav\Api\Data\AttributeOptionInterface[] $currentOptions */
44+
$currentOptions = $this->getItems($attributeCode);
45+
if (is_array($currentOptions)) {
46+
array_walk($currentOptions, function (&$attributeOption) {
47+
/** @var \Magento\Eav\Api\Data\AttributeOptionInterface $attributeOption */
48+
$attributeOption = $attributeOption->getLabel();
49+
});
50+
if (in_array($option->getLabel(), $currentOptions)) {
51+
return false;
52+
}
53+
}
4354
return $this->eavOptionManagement->add(
4455
\Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE,
4556
$attributeCode,

app/code/Magento/Catalog/Model/Product/Gallery/Processor.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ public function addImage(
192192
$mediaGalleryData['images'][] = [
193193
'file' => $fileName,
194194
'position' => $position,
195+
'media_type' => 'image',
195196
'label' => '',
196197
'disabled' => (int)$exclude,
197198
];

0 commit comments

Comments
 (0)