Skip to content

Commit

Permalink
MAGETWO-50528: Update oyejorge/less.php library to the new version
Browse files Browse the repository at this point in the history
- Merge remote-tracking branch 'mainline/develop' into MAGETWO-50528
  • Loading branch information
Evgeniy Kolesov committed Apr 28, 2016
2 parents 28bcde2 + 3fa0347 commit c5bee07
Show file tree
Hide file tree
Showing 1,274 changed files with 25,815 additions and 17,005 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -985,14 +985,14 @@ private function invokeMethod($object, $method, $args = [])
private function getAdvancedPricingMock($methods = [])
{
$metadataPoolMock = $this->getMock(
\Magento\Framework\Model\Entity\MetadataPool::class,
\Magento\Framework\EntityManager\MetadataPool::class,
[],
[],
'',
false
);
$metadataMock = $this->getMock(
\Magento\Framework\Model\Entity\EntityMetadata::class,
\Magento\Framework\EntityManager\EntityMetadata::class,
[],
[],
'',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,12 @@

use Magento\Framework\App\ObjectManager;
use Magento\Payment\Block\Transparent\Iframe;
use Magento\Framework\Escaper;

/**
* Class Redirect
*/
class Redirect extends \Magento\Authorizenet\Controller\Directpost\Payment
{
/**
* @var Escaper
*/
private $escaper;

/**
* Retrieve params and put javascript into iframe
*
Expand All @@ -29,7 +23,7 @@ public function execute()
{
$helper = $this->dataFactory->create('frontend');

$redirectParams = $this->filterData($this->getRequest()->getParams());
$redirectParams = $this->getRequest()->getParams();
$params = [];
if (!empty($redirectParams['success'])
&& isset($redirectParams['x_invoice_num'])
Expand All @@ -38,9 +32,11 @@ public function execute()
$this->_getDirectPostSession()->unsetData('quote_id');
$params['redirect_parent'] = $helper->getSuccessOrderUrl([]);
}

if (!empty($redirectParams['error_msg'])) {
$cancelOrder = empty($redirectParams['x_invoice_num']);
$this->_returnCustomerQuote($cancelOrder, $redirectParams['error_msg']);
$params['error_msg'] = $redirectParams['error_msg'];
}

if (isset($redirectParams['controller_action_name'])
Expand All @@ -50,34 +46,8 @@ public function execute()
unset($params['redirect_parent']);
}

$this->_coreRegistry->register(Iframe::REGISTRY_KEY, array_merge($params, $redirectParams));
$this->_coreRegistry->register(Iframe::REGISTRY_KEY, $params);
$this->_view->addPageLayoutHandles();
$this->_view->loadLayout(false)->renderLayout();
}

/**
* Escape xss in request data
* @param array $data
* @return array
*/
private function filterData(array $data)
{
$self = $this;
array_walk($data, function (&$item) use ($self) {
$item = $self->getEscaper()->escapeXssInUrl($item);
});
return $data;
}

/**
* Get Escaper instance
* @return Escaper
*/
private function getEscaper()
{
if (!$this->escaper) {
$this->escaper = ObjectManager::getInstance()->get(Escaper::class);
}
return $this->escaper;
}
}
24 changes: 22 additions & 2 deletions app/code/Magento/Authorizenet/Model/Directpost.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet implements Tra
*/
protected $transactionRepository;

/**
* @var \Psr\Log\LoggerInterface
*/
private $psrLogger;

/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
Expand Down Expand Up @@ -761,7 +766,7 @@ protected function addStatusComment(\Magento\Sales\Model\Order\Payment $payment)
{
try {
$transactionId = $this->getResponse()->getXTransId();
$data = $payment->getMethodInstance()->getTransactionDetails($transactionId);
$data = $this->transactionService->getTransactionDetails($this, $transactionId);
$transactionStatus = (string)$data->transaction->transactionStatus;
$fdsFilterAction = (string)$data->transaction->FDSFilterAction;

Expand All @@ -779,6 +784,7 @@ protected function addStatusComment(\Magento\Sales\Model\Order\Payment $payment)
$payment->getOrder()->addStatusHistoryComment($message);
}
} catch (\Exception $e) {
$this->getPsrLogger()->critical($e);
//this request is optional
}
return $this;
Expand All @@ -805,7 +811,7 @@ protected function declineOrder(\Magento\Sales\Model\Order $order, $message = ''
$order->registerCancellation($message)->save();
} catch (\Exception $e) {
//quiet decline
$this->logger->critical($e);
$this->getPsrLogger()->critical($e);
}
}

Expand Down Expand Up @@ -973,4 +979,18 @@ protected function getTransactionResponse($transactionId)

return $response;
}

/**
* @return \Psr\Log\LoggerInterface
*
* @deprecated
*/
private function getPsrLogger()
{
if (null === $this->psrLogger) {
$this->psrLogger = \Magento\Framework\App\ObjectManager::getInstance()
->get(\Psr\Log\LoggerInterface::class);
}
return $this->psrLogger;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Magento\Authorizenet\Controller\Directpost\Payment\Redirect;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\App\ViewInterface;
use Magento\Framework\Escaper;
use Magento\Framework\Registry;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Payment\Block\Transparent\Iframe;
Expand All @@ -34,11 +33,6 @@ class RedirectTest extends \PHPUnit_Framework_TestCase
*/
private $coreRegistry;

/**
* @var Escaper|MockObject
*/
private $escaper;

/**
* @var Redirect
*/
Expand All @@ -57,21 +51,11 @@ protected function setUp()
->setMethods(['register'])
->getMock();

$this->escaper = static::getMockBuilder(Escaper::class)
->disableOriginalConstructor()
->setMethods(['escapeXssInUrl'])
->getMock();

$this->controller = $objectManager->getObject(Redirect::class, [
'request' => $this->request,
'view' => $this->view,
'coreRegistry' => $this->coreRegistry
]);

$refClass = new \ReflectionClass(Redirect::class);
$refProperty = $refClass->getProperty('escaper');
$refProperty->setAccessible(true);
$refProperty->setValue($this->controller, $this->escaper);
}

/**
Expand All @@ -87,14 +71,9 @@ public function testExecute()
->method('getParams')
->willReturn($params);

$this->escaper->expects(static::once())
->method('escapeXssInUrl')
->with($url)
->willReturn($url);

$this->coreRegistry->expects(static::once())
->method('register')
->with(Iframe::REGISTRY_KEY, $params);
->with(Iframe::REGISTRY_KEY, []);

$this->view->expects(static::once())
->method('addPageLayoutHandles');
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Backend/App/BackendAppList.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public function getCurrentApp()
if ($appName && isset($this->backendApps[$appName])) {
return $this->backendApps[$appName];
}
return null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,12 @@ protected function _prepareStoreFieldset(\Magento\Framework\Data\Form $form)
'disabled' => $groupModel->isReadOnly()
]
);

if ($this->_coreRegistry->registry('store_action') == 'edit') {
$stores = $this->_storeFactory->create()->getCollection()->addGroupFilter(
$groupModel->getId()
)->toOptionArray();
$storeActive = 1;
$stores = $this->_storeFactory->create()->getCollection()
->addGroupFilter($groupModel->getId())
->addStatusFilter($storeActive)
->toOptionArray();
$fieldset->addField(
'group_default_store_id',
'select',
Expand Down
61 changes: 39 additions & 22 deletions app/code/Magento/Backend/Block/System/Store/Edit/Form/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public function __construct(
*
* @param \Magento\Framework\Data\Form $form
* @return void
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
protected function _prepareStoreFieldset(\Magento\Framework\Data\Form $form)
{
Expand All @@ -75,27 +74,7 @@ protected function _prepareStoreFieldset(\Magento\Framework\Data\Form $form)
'disabled' => $storeModel->isReadOnly()
]
);
if ($storeModel->getId() && $storeModel->getGroup()->getDefaultStoreId() == $storeModel->getId()) {
if ($storeModel->getGroup() && $storeModel->getGroup()->getStoresCount() > 1) {
$form->getElement('store_group_id')->setDisabled(true);

$fieldset->addField(
'store_hidden_group_id',
'hidden',
['name' => 'store[group_id]', 'no_span' => true, 'value' => $storeModel->getGroupId()]
);
} else {
$fieldset->addField(
'store_original_group_id',
'hidden',
[
'name' => 'store[original_group_id]',
'no_span' => true,
'value' => $storeModel->getGroupId()
]
);
}
}
$fieldset = $this->prepareGroupIdField($form, $storeModel, $fieldset);
}

$fieldset->addField(
Expand Down Expand Up @@ -131,6 +110,7 @@ protected function _prepareStoreFieldset(\Magento\Framework\Data\Form $form)
'options' => [0 => __('Disabled'), 1 => __('Enabled')],
'required' => true,
'disabled' => $storeModel->isReadOnly()
|| ($storeModel->getId() && $storeModel->isDefault() && $storeModel->isActive())
]
);

Expand Down Expand Up @@ -185,4 +165,41 @@ protected function _getStoreGroups()
}
return $groups;
}

/**
* Prepare group id field in the fieldset
*
* @param \Magento\Framework\Data\Form $form
* @param \Magento\Store\Model\Store $storeModel
* @param \Magento\Framework\Data\Form\Element\Fieldset $fieldset
* @return \Magento\Framework\Data\Form\Element\Fieldset
*/
private function prepareGroupIdField(
\Magento\Framework\Data\Form $form,
\Magento\Store\Model\Store $storeModel,
\Magento\Framework\Data\Form\Element\Fieldset $fieldset
) {
if ($storeModel->getId() && $storeModel->getGroup()->getDefaultStoreId() == $storeModel->getId()) {
if ($storeModel->getGroup() && $storeModel->getGroup()->getStoresCount() > 1) {
$form->getElement('store_group_id')->setDisabled(true);

$fieldset->addField(
'store_hidden_group_id',
'hidden',
['name' => 'store[group_id]', 'no_span' => true, 'value' => $storeModel->getGroupId()]
);
} else {
$fieldset->addField(
'store_original_group_id',
'hidden',
[
'name' => 'store[original_group_id]',
'no_span' => true,
'value' => $storeModel->getGroupId()
]
);
}
}
return $fieldset;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ protected function _toOptionHtml($action, \Magento\Framework\DataObject $row)
$actionCaption = '';
$this->_transformActionData($action, $actionCaption, $row);

$htmlAttibutes = ['value' => $this->escapeHtml($this->_jsonEncoder->encode($action))];
$actionAttributes->setData($htmlAttibutes);
$htmlAttributes = ['value' => $this->escapeHtml($this->_jsonEncoder->encode($action))];
$actionAttributes->setData($htmlAttributes);
return '<option ' . $actionAttributes->serialize() . '>' . $actionCaption . '</option>';
}

Expand Down
Loading

0 comments on commit c5bee07

Please sign in to comment.