Skip to content

Commit

Permalink
Merge remote-tracking branch 'mainline/develop' into MAGETWO-54693
Browse files Browse the repository at this point in the history
  • Loading branch information
Olexandr Lysenko committed Oct 3, 2016
2 parents 22e67c2 + 6614360 commit f11594d
Show file tree
Hide file tree
Showing 345 changed files with 17,102 additions and 2,768 deletions.
Expand Up @@ -35,8 +35,12 @@ $ccExpYear = $block->getInfoData('cc_exp_year');
</label>
<div class="admin__field-control">
<select id="<?php /* @noEscape */ echo $code; ?>_cc_type" name="payment[cc_type]"
class="required-entry validate-cc-type-select admin__control-select">
<option value=""></option>
class="admin__control-select"
data-validate="{
'required':true,
'validate-cc-type-select':'#<?php /* @noEscape */ echo $code; ?>_cc_number'
}">
<option value=""><?php echo $block->escapeHtml(__('Please Select')); ?></option>
<?php foreach ($block->getCcAvailableTypes() as $typeCode => $typeName): ?>
<option value="<?php echo $block->escapeHtml($typeCode); ?>"
<?php if ($typeCode == $ccType): ?>selected="selected"<?php endif; ?>>
Expand All @@ -46,27 +50,37 @@ $ccExpYear = $block->getInfoData('cc_exp_year');
</select>
</div>
</div>

<div class="admin__field _required">
<label for="<?php /* @noEscape */ echo $code; ?>_cc_number" class="admin__field-label">
<span><?php echo $block->escapeHtml(__('Credit Card Number')); ?></span>
</label>

<div class="admin__field-control">
<input type="text" id="<?php /* @noEscape */ echo $code; ?>_cc_number"
name="payment[cc_number]"
class="input-text required-entry validate-cc-number admin__control-text"
data-validate="{
'required-number':true,
'validate-cc-number':'#<?php /* @noEscape */ echo $code; ?>_cc_type',
'validate-cc-type':'#<?php /* @noEscape */ echo $code; ?>_cc_type'
}"
class="admin__control-text"
value="<?php /* @noEscape */ echo $block->getInfoData('cc_number'); ?>"/>
</div>
</div>
<div class="admin__field _required">

<div class="admin__field _required field-date" id="<?php /* @noEscape */ echo $code; ?>_cc_type_exp_div">
<label for="<?php /* @noEscape */ echo $code; ?>_expiration" class="admin__field-label">
<span><?php echo $block->escapeHtml(__('Expiration Date')); ?></span>
</label>

<div class="admin__field-control">
<select id="<?php /* @noEscape */ echo $code; ?>_expiration"
name="payment[cc_exp_month]"
class="validate-cc-exp required-entry admin__control-select admin__control-select-month">
class="admin__control-select admin__control-select-month"
data-validate="{
'required':true,
'validate-cc-exp':'#<?php /* @noEscape */ echo $code; ?>_expiration_yr'
}">
<?php foreach ($block->getCcMonths() as $k => $v): ?>
<option value="<?php echo $block->escapeHtml($k); ?>"
<?php if ($k == $ccExpMonth): ?>selected="selected"<?php endif; ?>>
Expand All @@ -76,7 +90,9 @@ $ccExpYear = $block->getInfoData('cc_exp_year');
</select>
<select id="<?php /* @noEscape */ echo $code; ?>_expiration_yr"
name="payment[cc_exp_year]"
class="required-entry admin__control-select admin__control-select-year">
class="admin__control-select admin__control-select-year"
data-container="<?php /* @noEscape */ echo $code; ?>-cc-year"
data-validate="{required:true}">
<?php foreach ($block->getCcYears() as $k => $v): ?>
<option value="<?php /* @noEscape */ echo $k ? $block->escapeHtml($k) : ''; ?>"
<?php if ($k == $ccExpYear): ?>selected="selected"<?php endif; ?>>
Expand All @@ -86,17 +102,27 @@ $ccExpYear = $block->getInfoData('cc_exp_year');
</select>
</div>
</div>

<?php if ($block->hasVerification()): ?>
<div class="admin__field _required">
<label for="<?php /* @noEscape */ echo $code; ?>_cc_cid">
<div class="admin__field _required field-cvv">
<label class="admin__field-label"
for="<?php /* @noEscape */ echo $code; ?>_cc_cid"
id="<?php /* @noEscape */ echo $code; ?>_cc_type_cvv_div">
<span><?php echo $block->escapeHtml(__('Card Verification Number')); ?></span>
</label>

<div class="admin__field-control">
<input type="text"
class="required-entry input-text validate-cc-cvn admin__control-text"
data-container="<?php /* @noEscape */ echo $code; ?>-cc-cvv"
title="<?php echo $block->escapeHtml(__('Card Verification Number')); ?>"
class="admin__control-text cvv"
id="<?php /* @noEscape */ echo $code; ?>_cc_cid" name="payment[cc_cid]"
value="<?php /* @noEscape */ echo $block->getInfoData('cc_cid') ?>"/>
value="<?php /* @noEscape */ echo $block->getInfoData('cc_cid') ?>"
data-validate="{
'required-number':true,
'validate-cc-cvn':'#<?php /* @noEscape */ echo $code; ?>_cc_type'
}"
autocomplete="off"/>
</div>
</div>
<?php endif; ?>
Expand All @@ -105,7 +131,7 @@ $ccExpYear = $block->getInfoData('cc_exp_year');
require([
'prototype',
'Magento_Sales/order/create/scripts',
"Magento_Sales/order/create/form",
'Magento_Sales/order/create/form',
'Magento_Authorizenet/js/direct-post'
], function(){

Expand Down
15 changes: 7 additions & 8 deletions app/code/Magento/Braintree/Helper/Country.php
Expand Up @@ -6,19 +6,20 @@
namespace Magento\Braintree\Helper;

use Magento\Directory\Model\ResourceModel\Country\CollectionFactory;
use Magento\Braintree\Model\Adminhtml\System\Config\Country as CountryConfig;

/**
* Class Country
*/
class Country
{
/**
* @var \Magento\Directory\Model\ResourceModel\Country\CollectionFactory
* @var CollectionFactory
*/
private $collectionFactory;

/**
* @var \Magento\Braintree\Model\Adminhtml\System\Config\Country
* @var CountryConfig
*/
private $countryConfig;

Expand All @@ -28,13 +29,11 @@ class Country
private $countries;

/**
* @param \Magento\Directory\Model\ResourceModel\Country\CollectionFactory $factory
* @param \Magento\Braintree\Model\Adminhtml\System\Config\Country $countryConfig
* @param CollectionFactory $factory
* @param CountryConfig $countryConfig
*/
public function __construct(
\Magento\Directory\Model\ResourceModel\Country\CollectionFactory $factory,
\Magento\Braintree\Model\Adminhtml\System\Config\Country $countryConfig
) {
public function __construct(CollectionFactory $factory, CountryConfig $countryConfig)
{
$this->collectionFactory = $factory;
$this->countryConfig = $countryConfig;
}
Expand Down
19 changes: 18 additions & 1 deletion app/code/Magento/Braintree/etc/di.xml
Expand Up @@ -22,6 +22,7 @@
<argument name="code" xsi:type="const">Magento\Braintree\Model\Ui\PayPal\ConfigProvider::PAYPAL_CODE</argument>
<argument name="infoBlockType" xsi:type="string">BraintreePayPalInfo</argument>
<argument name="valueHandlerPool" xsi:type="object">BraintreePayPalValueHandlerPool</argument>
<argument name="validatorPool" xsi:type="object">BraintreePayPalValidatorPool</argument>
<argument name="commandPool" xsi:type="object">BraintreePayPalCommandPool</argument>
</arguments>
</virtualType>
Expand Down Expand Up @@ -474,7 +475,7 @@
</arguments>
</virtualType>

<!-- Value validators infrastructure -->
<!-- Braintree validators infrastructure -->
<virtualType name="BraintreeCountryValidator" type="Magento\Payment\Gateway\Validator\CountryValidator">
<arguments>
<argument name="config" xsi:type="object">Magento\Braintree\Gateway\Config\Config</argument>
Expand All @@ -487,6 +488,22 @@
</argument>
</arguments>
</virtualType>
<!-- Braintree validators infrastructure -->

<!-- Braintree PayPal validators -->
<virtualType name="BraintreePayPalCountryValidator" type="Magento\Payment\Gateway\Validator\CountryValidator">
<arguments>
<argument name="config" xsi:type="object">Magento\Braintree\Gateway\Config\PayPal\Config</argument>
</arguments>
</virtualType>
<virtualType name="BraintreePayPalValidatorPool" type="Magento\Payment\Gateway\Validator\ValidatorPool">
<arguments>
<argument name="validators" xsi:type="array">
<item name="country" xsi:type="string">BraintreePayPalCountryValidator</item>
</argument>
</arguments>
</virtualType>
<!-- END Braintree PayPal validators -->

<type name="Magento\Braintree\Block\Info">
<arguments>
Expand Down
Expand Up @@ -12,8 +12,19 @@ define([
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/model/full-screen-loader',
'Magento_Checkout/js/model/payment/additional-validators',
'Magento_Vault/js/view/payment/vault-enabler'
], function ($, _, Component, Braintree, quote, fullScreenLoader, additionalValidators, VaultEnabler) {
'Magento_Vault/js/view/payment/vault-enabler',
'Magento_Checkout/js/action/create-billing-address'
], function (
$,
_,
Component,
Braintree,
quote,
fullScreenLoader,
additionalValidators,
VaultEnabler,
createBillingAddress
) {
'use strict';

return Component.extend({
Expand Down Expand Up @@ -172,14 +183,16 @@ define([
var billingAddress = {
street: [address.streetAddress],
city: address.locality,
regionCode: address.region,
postcode: address.postalCode,
countryId: address.countryCodeAlpha2,
email: customer.email,
firstname: customer.firstName,
lastname: customer.lastName,
telephone: customer.phone
};

billingAddress['region_code'] = address.region;
billingAddress = createBillingAddress(billingAddress);
quote.billingAddress(billingAddress);
},

Expand Down
Expand Up @@ -109,8 +109,8 @@
<input type="checkbox"
name="vault[is_enabled]"
class="checkbox"
data-bind="attr: {'id': getCode() + '_vault_enabler'}, checked: vaultEnabler.isActivePaymentTokenEnabler"/>
<label class="label" data-bind="attr: {'for': getCode() + '_vault_enabler'}">
data-bind="attr: {'id': getCode() + '_enable_vault'}, checked: vaultEnabler.isActivePaymentTokenEnabler"/>
<label class="label" data-bind="attr: {'for': getCode() + '_enable_vault'}">
<span><!-- ko i18n: 'Save for later use.'--><!-- /ko --></span>
</label>
<div class="field-tooltip toggle">
Expand Down
Expand Up @@ -32,8 +32,8 @@
<input type="checkbox"
name="vault[is_enabled]"
class="checkbox"
data-bind="attr: {'id': getCode() + '_vault_enabler'}, checked: vaultEnabler.isActivePaymentTokenEnabler"/>
<label class="label" data-bind="attr: {'for': getCode() + '_vault_enabler'}">
data-bind="attr: {'id': getCode() + '_enable_vault'}, checked: vaultEnabler.isActivePaymentTokenEnabler"/>
<label class="label" data-bind="attr: {'for': getCode() + '_enable_vault'}">
<span><!-- ko i18n: 'Save for later use.'--><!-- /ko --></span>
</label>
<div class="field-tooltip toggle">
Expand Down
44 changes: 31 additions & 13 deletions app/code/Magento/BundleImportExport/Model/Export/RowCustomizer.php
Expand Up @@ -331,10 +331,7 @@ private function getShipmentTypeValue($type)
protected function cleanNotBundleAdditionalAttributes($dataRow)
{
if (!empty($dataRow['additional_attributes'])) {
$additionalAttributes = explode(
ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR,
$dataRow['additional_attributes']
);
$additionalAttributes = $this->parseAdditionalAttributes($dataRow['additional_attributes']);
$dataRow['additional_attributes'] = $this->getNotBundleAttributes($additionalAttributes);
}

Expand All @@ -349,17 +346,38 @@ protected function cleanNotBundleAdditionalAttributes($dataRow)
*/
protected function getNotBundleAttributes($additionalAttributes)
{
$cleanedAdditionalAttributes = '';
foreach ($additionalAttributes as $attribute) {
list($attributeCode, $attributeValue) = explode(ImportProductModel::PAIR_NAME_VALUE_SEPARATOR, $attribute);
if (!in_array('bundle_' . $attributeCode, $this->getBundleColumns())) {
$cleanedAdditionalAttributes .= $attributeCode
. ImportProductModel::PAIR_NAME_VALUE_SEPARATOR
. $attributeValue
. ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR;
$filteredAttributes = [];
foreach ($additionalAttributes as $code => $value) {
if (!in_array('bundle_' . $code, $this->getBundleColumns())) {
$filteredAttributes[] = $code . ImportProductModel::PAIR_NAME_VALUE_SEPARATOR . $value;
}
}
return implode(ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $filteredAttributes);
}

return rtrim($cleanedAdditionalAttributes, ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR);
/**
* Retrieves additional attributes as array code=>value.
*
* @param string $additionalAttributes
* @return array
*/
private function parseAdditionalAttributes($additionalAttributes)
{
$attributeNameValuePairs = explode(ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $additionalAttributes);
$preparedAttributes = [];
$code = '';
foreach ($attributeNameValuePairs as $attributeData) {
//process case when attribute has ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR inside its value
if (strpos($attributeData, ImportProductModel::PAIR_NAME_VALUE_SEPARATOR) === false) {
if (!$code) {
continue;
}
$preparedAttributes[$code] .= ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR . $attributeData;
continue;
}
list($code, $value) = explode(ImportProductModel::PAIR_NAME_VALUE_SEPARATOR, $attributeData, 2);
$preparedAttributes[$code] = $value;
}
return $preparedAttributes;
}
}
Expand Up @@ -178,15 +178,16 @@ public function testAddHeaderColumns()
public function testAddData()
{
$preparedData = $this->rowCustomizerMock->prepareData($this->productResourceCollection, [1]);
$attributes = 'attribute=1,sku_type=1,price_type=1,price_view=1,weight_type=1,values=values,shipment_type=1';
$attributes = 'attribute=1,sku_type=1,attribute2="Text",price_type=1,price_view=1,weight_type=1,'
. 'values=values,shipment_type=1,attribute3=One,Two,Three';
$dataRow = [
'sku' => 'sku1',
'additional_attributes' => $attributes
];
$preparedRow = $preparedData->addData($dataRow, 1);
$expected = [
'sku' => 'sku1',
'additional_attributes' => 'attribute=1',
'additional_attributes' => 'attribute=1,attribute2="Text",attribute3=One,Two,Three',
'bundle_price_type' => 'fixed',
'bundle_shipment_type' => 'separately',
'bundle_sku_type' => 'fixed',
Expand Down
Expand Up @@ -5,6 +5,7 @@
*/
namespace Magento\CacheInvalidate\Observer;

use Magento\Framework\App\ObjectManager;
use Magento\Framework\Event\ObserverInterface;

class InvalidateVarnishObserver implements ObserverInterface
Expand All @@ -21,6 +22,13 @@ class InvalidateVarnishObserver implements ObserverInterface
*/
protected $purgeCache;

/**
* Invalidation tags resolver
*
* @var \Magento\Framework\App\Cache\Tag\Resolver
*/
private $tagResolver;

/**
* @param \Magento\PageCache\Model\Config $config
* @param \Magento\CacheInvalidate\Model\PurgeCache $purgeCache
Expand All @@ -42,18 +50,35 @@ public function __construct(
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
$object = $observer->getEvent()->getObject();
if (!is_object($object)) {
return;
}
if ($this->config->getType() == \Magento\PageCache\Model\Config::VARNISH && $this->config->isEnabled()) {
$object = $observer->getEvent()->getObject();
if ($object instanceof \Magento\Framework\DataObject\IdentityInterface) {
$tags = [];
$pattern = "((^|,)%s(,|$))";
foreach ($object->getIdentities() as $tag) {
$tags[] = sprintf($pattern, $tag);
}
if (!empty($tags)) {
$this->purgeCache->sendPurgeRequest(implode('|', array_unique($tags)));
}
$bareTags = $this->getTagResolver()->getTags($object);

$tags = [];
$pattern = "((^|,)%s(,|$))";
foreach ($bareTags as $tag) {
$tags[] = sprintf($pattern, $tag);
}
if (!empty($tags)) {
$this->purgeCache->sendPurgeRequest(implode('|', array_unique($tags)));
}

}
}

/**
* @deprecated
* @return \Magento\Framework\App\Cache\Tag\Resolver
*/
private function getTagResolver()
{
if ($this->tagResolver === null) {
$this->tagResolver = \Magento\Framework\App\ObjectManager::getInstance()
->get(\Magento\Framework\App\Cache\Tag\Resolver::class);
}
return $this->tagResolver;
}
}

0 comments on commit f11594d

Please sign in to comment.