Skip to content

Commit

Permalink
Merge pull request magento#3575 from magento-tsg/2.2-develop-pr66
Browse files Browse the repository at this point in the history
[TSG] Backporting for 2.2 (pr66) (2.2.8)
  • Loading branch information
xmav authored Jan 4, 2019
2 parents a5df627 + 794b3b0 commit 88e5cda
Show file tree
Hide file tree
Showing 38 changed files with 687 additions and 295 deletions.
1 change: 1 addition & 0 deletions app/code/Magento/Authorizenet/Model/Directpost.php
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,7 @@ protected function declineOrder(\Magento\Sales\Model\Order $order, $message = ''
->void($response);
}
$order->registerCancellation($message)->save();
$this->_eventManager->dispatch('order_cancel_after', ['order' => $order ]);
} catch (\Exception $e) {
//quiet decline
$this->getPsrLogger()->critical($e);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="CustomerLogoutStorefrontByMenuItemsActionGroup">
<conditionalClick selector="{{StorefrontPanelHeaderSection.customerWelcome}}"
dependentSelector="{{StorefrontPanelHeaderSection.customerWelcomeMenu}}"
visible="false"
stepKey="clickHeaderCustomerMenuButton" />
<click selector="{{StorefrontPanelHeaderSection.customerLogoutLink}}" stepKey="clickSignOutButton" />
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
-->

<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
<section name="StorefrontPanelHeaderSection">
<element name="createAnAccountLink" type="select" selector=".panel.header li:nth-child(3)"/>
<element name="customerWelcome" type="text" selector=".panel.header .customer-welcome"/>
<element name="customerWelcomeMenu" type="text" selector=".panel.header .customer-welcome .customer-menu"/>
<element name="customerLogoutLink" type="text" selector=".panel.header .customer-welcome .customer-menu .authorization-link a" timeout="30"/>
<element name="welcomeMessage" type="text" selector=".greet.welcome span"/>
<element name="notYouLink" type="button" selector=".greet.welcome span a"/>
</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

use Magento\ImportExport\Controller\Adminhtml\ImportResult as ImportResultController;
use Magento\Framework\Controller\ResultFactory;
use Magento\ImportExport\Model\Import;

/**
* Controller responsible for initiating the import process.
*/
class Start extends ImportResultController
{
/**
Expand Down Expand Up @@ -62,6 +66,11 @@ public function execute()

$this->importModel->setData($data);
$errorAggregator = $this->importModel->getErrorAggregator();
$errorAggregator->initValidationStrategy(
$this->importModel->getData(Import::FIELD_NAME_VALIDATION_STRATEGY),
$this->importModel->getData(Import::FIELD_NAME_ALLOWED_ERROR_COUNT)
);

try {
$this->importModel->importSource();
} catch (\Exception $e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@
</div>
<?php endif;?>
</div>
<iframe name="preview_iframe" id="preview_iframe" frameborder="0" title="<?= $block->escapeHtmlAttr(__('Preview')) ?>" width="100%"></iframe>
<iframe
name="preview_iframe"
id="preview_iframe"
frameborder="0"
title="<?= $block->escapeHtmlAttr(__('Preview')) ?>"
width="100%"
sandbox="allow-forms allow-pointer-lock allow-scripts">
</iframe>
<?= $block->getChildHtml('preview_form') ?>
</div>

Expand Down
53 changes: 42 additions & 11 deletions app/code/Magento/Persistent/Block/Header/Additional.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
*/
namespace Magento\Persistent\Block\Header;

use Magento\Framework\App\ObjectManager;
use Magento\Framework\Serialize\Serializer\Json;
use Magento\Persistent\Helper\Data;

/**
* Remember Me block
*
Expand All @@ -30,27 +34,46 @@ class Additional extends \Magento\Framework\View\Element\Html\Link
protected $customerRepository;

/**
* Constructor
*
* @var string
*/
protected $_template = 'Magento_Persistent::additional.phtml';

/**
* @var Json
*/
private $jsonSerializer;

/**
* @var Data
*/
private $persistentHelper;

/**
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Customer\Helper\View $customerViewHelper
* @param \Magento\Persistent\Helper\Session $persistentSessionHelper
* @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository
* @param array $data
* @param Json|null $jsonSerializer
* @param Data|null $persistentHelper
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Customer\Helper\View $customerViewHelper,
\Magento\Persistent\Helper\Session $persistentSessionHelper,
\Magento\Customer\Api\CustomerRepositoryInterface $customerRepository,
array $data = []
array $data = [],
Json $jsonSerializer = null,
Data $persistentHelper = null
) {
$this->isScopePrivate = true;
$this->_customerViewHelper = $customerViewHelper;
$this->_persistentSessionHelper = $persistentSessionHelper;
$this->customerRepository = $customerRepository;
parent::__construct($context, $data);
$this->_isScopePrivate = true;
$this->jsonSerializer = $jsonSerializer ?: ObjectManager::getInstance()->get(Json::class);
$this->persistentHelper = $persistentHelper ?: ObjectManager::getInstance()->get(Data::class);
}

/**
Expand All @@ -64,17 +87,25 @@ public function getHref()
}

/**
* Render additional header html
* @return int
*/
public function getCustomerId()
{
return $this->_persistentSessionHelper->getSession()->getCustomerId();
}

/**
* Get persistent config.
*
* @return string
*/
protected function _toHtml()
public function getConfig()
{
if ($this->_persistentSessionHelper->getSession()->getCustomerId()) {
return '<span><a ' . $this->getLinkAttributes() . ' >' . __('Not you?')
. '</a></span>';
}

return '';
return
$this->jsonSerializer->serialize(
[
'expirationLifetime' => $this->persistentHelper->getLifeTime(),
]
);
}
}
71 changes: 71 additions & 0 deletions app/code/Magento/Persistent/CustomerData/Persistent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Persistent\CustomerData;

use Magento\Customer\Api\CustomerRepositoryInterface;
use Magento\Customer\CustomerData\SectionSourceInterface;
use Magento\Customer\Helper\View;
use Magento\Persistent\Helper\Session;

/**
* Customer persistent section
*/
class Persistent implements SectionSourceInterface
{
/**
* @var Session
*/
private $persistentSession;

/**
* @var View
*/
private $customerViewHelper;

/**
* @var CustomerRepositoryInterface
*/
private $customerRepository;

/**
* @param Session $persistentSession
* @param View $customerViewHelper
* @param CustomerRepositoryInterface $customerRepository
*/
public function __construct(
Session $persistentSession,
View $customerViewHelper,
CustomerRepositoryInterface $customerRepository
) {
$this->persistentSession = $persistentSession;
$this->customerViewHelper = $customerViewHelper;
$this->customerRepository = $customerRepository;
}

/**
* Get data
*
* @return array
*/
public function getSectionData()
{
if (!$this->persistentSession->isPersistent()) {
return [];
}

$customerId = $this->persistentSession->getSession()->getCustomerId();
if (!$customerId) {
return [];
}

$customer = $this->customerRepository->getById($customerId);

return [
'fullname' => $this->customerViewHelper->getCustomerName($customer),
];
}
}
7 changes: 1 addition & 6 deletions app/code/Magento/Persistent/Model/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,8 @@ public function __construct(
*/
public function emulateWelcomeBlock($block)
{
$customerName = $this->_customerViewHelper->getCustomerName(
$this->customerRepository->getById($this->_persistentSession->getSession()->getCustomerId())
);
$block->setWelcome('&nbsp;');

$this->_applyAccountLinksPersistentData();
$welcomeMessage = __('Welcome, %1!', $customerName);
$block->setWelcome($welcomeMessage);
return $this;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Persistent\Model\Plugin;

/**
* Plugin for Magento\Framework\App\Http\Context to create new page cache variation for persistent session.
*/
class PersistentCustomerContext
{
/**
* Persistent session
*
* @var \Magento\Persistent\Helper\Session
*/
private $persistentSession;

/**
* @param \Magento\Persistent\Helper\Session $persistentSession
*/
public function __construct(
\Magento\Persistent\Helper\Session $persistentSession
) {
$this->persistentSession = $persistentSession;
}

/**
* @param \Magento\Framework\App\Http\Context $subject
* @return mixed
*/
public function beforeGetVaryString(\Magento\Framework\App\Http\Context $subject)
{
if ($this->persistentSession->isPersistent()) {
$subject->setValue('PERSISTENT', 1, 0);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="CustomerLoginOnStorefrontWithRememberMeChecked" extends="CustomerLoginOnStorefront">
<checkOption selector="{{StorefrontCustomerSignInFormSection.rememberMe}}"
before="clickSignInAccountButton"
stepKey="checkRememberMe"/>
</actionGroup>

<actionGroup name="CustomerLoginOnStorefrontWithRememberMeUnChecked" extends="CustomerLoginOnStorefront">
<uncheckOption selector="{{StorefrontCustomerSignInFormSection.rememberMe}}"
before="clickSignInAccountButton"
stepKey="unCheckRememberMe"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
<section name="StorefrontCustomerSignInFormSection">
<element name="rememberMe" type="checkbox" selector="[name='persistent_remember_me']"/>
</section>
</sections>
Loading

0 comments on commit 88e5cda

Please sign in to comment.