Skip to content

Commit a626f84

Browse files
author
Natalia Momotenko
committed
Merge remote-tracking branch 'origin/develop' into PR-2
2 parents 914ef79 + 0efa2bc commit a626f84

File tree

60 files changed

+2065
-1013
lines changed

Some content is hidden

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

60 files changed

+2065
-1013
lines changed

app/code/Magento/Braintree/Model/PaymentMethod.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use \Braintree_Transaction;
1212
use \Braintree_Result_Successful;
1313
use Magento\Framework\Exception\LocalizedException;
14+
use Magento\Sales\Model\Order\Payment\Transaction;
1415
use Magento\Sales\Model\ResourceModel\Order\Payment\Transaction\CollectionFactory as TransactionCollectionFactory;
1516
use Magento\Sales\Model\Order\Payment\Transaction as PaymentTransaction;
1617
use Magento\Payment\Model\InfoInterface;
@@ -648,13 +649,15 @@ public function refund(InfoInterface $payment, $amount)
648649
}
649650
}
650651

652+
// transaction should be voided if it not settled
651653
$canVoid = ($transaction->status === \Braintree_Transaction::AUTHORIZED
652654
|| $transaction->status === \Braintree_Transaction::SUBMITTED_FOR_SETTLEMENT);
653655
$result = $canVoid
654656
? $this->braintreeTransaction->void($transactionId)
655657
: $this->braintreeTransaction->refund($transactionId, $amount);
656658
$this->_debug($this->_convertObjToArray($result));
657659
if ($result->success) {
660+
$payment->setTransactionId($transactionId . '-' . Transaction::TYPE_REFUND);
658661
$payment->setIsTransactionClosed(true);
659662
} else {
660663
throw new LocalizedException($this->errorHelper->parseBraintreeError($result));

app/code/Magento/Braintree/Test/Unit/Model/PaymentMethodTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
use Magento\Braintree\Model\PaymentMethod;
1010
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
11+
use Magento\Sales\Model\Order\Payment\Transaction;
1112
use \Magento\Sales\Model\ResourceModel\Order\Payment\Transaction\CollectionFactory as TransactionCollectionFactory;
1213
use Magento\Framework\Exception\LocalizedException;
1314
use \Braintree_Result_Successful;
@@ -2378,6 +2379,7 @@ public function testRefund()
23782379

23792380
$this->model->refund($paymentObject, $amount);
23802381
$this->assertEquals(1, $paymentObject->getIsTransactionClosed());
2382+
$this->assertEquals($refundTransactionId . '-' .Transaction::TYPE_REFUND, $paymentObject->getTransactionId());
23812383
}
23822384

23832385
/**

app/code/Magento/Braintree/view/adminhtml/templates/form.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ $ccExpYear = $block->getInfoData('cc_exp_year');
133133
</div>
134134
</fieldset>
135135
<?php endif; ?>
136-
<?php if($_useVault): ?>
136+
<?php if($useVault): ?>
137137
<fieldset class="admin__fieldset hide_if_token_selected">
138138
<div id="<?php /* @noEscape */ echo $code; ?>_store_in_vault_div" style="text-align:left;" class="">
139139
<input type="checkbox" title="<?php echo $block->escapeHtml(__('Save this card for future use')); ?>"

app/code/Magento/Braintree/view/frontend/templates/creditcard/index.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ $storedCards = $block->getCurrentCustomerStoredCards();
1919
<?php endif; ?>
2020
</div>
2121
<?php echo $block->getLayout()->getMessagesBlock()->getGroupedHtml(); ?>
22-
<?php if (count($_storedCards)): ?>
22+
<?php if (count($storedCards)): ?>
2323
<table class="data-table" id="my-quotes-table">
2424
<col width="1" />
2525
<col width="1" />

app/code/Magento/Deploy/Model/Deployer.php

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Magento\Deploy\Model;
88

9+
use Magento\Framework\View\Asset\PreProcessor\AlternativeSourceInterface;
910
use Magento\Framework\App\ObjectManagerFactory;
1011
use Magento\Framework\App\View\Deployment\Version;
1112
use Magento\Framework\App\View\Asset\Publisher;
@@ -19,6 +20,7 @@
1920
* A service for deploying Magento static view files for production mode
2021
*
2122
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
23+
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
2224
*/
2325
class Deployer
2426
{
@@ -66,17 +68,26 @@ class Deployer
6668
protected $jsTranslationConfig;
6769

6870
/**
71+
* @var AlternativeSourceInterface[]
72+
*/
73+
private $alternativeSources;
74+
75+
/**
76+
* Constructor
77+
*
6978
* @param Files $filesUtil
7079
* @param OutputInterface $output
7180
* @param Version\StorageInterface $versionStorage
7281
* @param JsTranslationConfig $jsTranslationConfig
82+
* @param AlternativeSourceInterface[] $alternativeSources
7383
* @param bool $isDryRun
7484
*/
7585
public function __construct(
7686
Files $filesUtil,
7787
OutputInterface $output,
7888
Version\StorageInterface $versionStorage,
7989
JsTranslationConfig $jsTranslationConfig,
90+
array $alternativeSources,
8091
$isDryRun = false
8192
) {
8293
$this->filesUtil = $filesUtil;
@@ -85,6 +96,13 @@ public function __construct(
8596
$this->isDryRun = $isDryRun;
8697
$this->jsTranslationConfig = $jsTranslationConfig;
8798
$this->parentTheme = [];
99+
100+
array_map(
101+
function (AlternativeSourceInterface $alternative) {
102+
},
103+
$alternativeSources
104+
);
105+
$this->alternativeSources = $alternativeSources;
88106
}
89107

90108
/**
@@ -124,6 +142,7 @@ public function deploy(ObjectManagerFactory $omFactory, array $locales)
124142
'design' => $design,
125143
]
126144
);
145+
/** @var \Magento\RequireJs\Model\FileManager $fileManager */
127146
$fileManager = $this->objectManager->create(
128147
'Magento\RequireJs\Model\FileManager',
129148
[
@@ -148,11 +167,17 @@ public function deploy(ObjectManagerFactory $omFactory, array $locales)
148167
$this->findAncestors($area . Theme::THEME_PATH_SEPARATOR . $themePath)
149168
))
150169
) {
151-
$this->deployFile($filePath, $area, $themePath, $locale, $module);
170+
$compiledFile = $this->deployFile($filePath, $area, $themePath, $locale, $module);
171+
if ($compiledFile !== '') {
172+
$this->deployFile($compiledFile, $area, $themePath, $locale, $module);
173+
}
152174
}
153175
}
154176
foreach ($libFiles as $filePath) {
155-
$this->deployFile($filePath, $area, $themePath, $locale, null);
177+
$compiledFile = $this->deployFile($filePath, $area, $themePath, $locale, null);
178+
if ($compiledFile !== '') {
179+
$this->deployFile($compiledFile, $area, $themePath, $locale, null);
180+
}
156181
}
157182
if ($this->jsTranslationConfig->dictionaryEnabled()) {
158183
$this->deployFile(
@@ -169,7 +194,7 @@ public function deploy(ObjectManagerFactory $omFactory, array $locales)
169194
}
170195
}
171196
}
172-
$this->output->writeln("=== Minify templates ===");
197+
$this->output->writeln('=== Minify templates ===');
173198
$this->count = 0;
174199
foreach ($this->filesUtil->getPhtmlFiles(false, false) as $template) {
175200
$this->htmlMinifier->minify($template);
@@ -268,15 +293,25 @@ protected function emulateApplicationLocale($locale, $area)
268293
* @param string $themePath
269294
* @param string $locale
270295
* @param string $module
271-
* @return void
296+
* @return string
297+
* @throws \InvalidArgumentException
298+
*
272299
* @SuppressWarnings(PHPMD.NPathComplexity)
273300
*/
274301
private function deployFile($filePath, $area, $themePath, $locale, $module)
275302
{
276-
$requestedPath = $filePath;
277-
if (substr($filePath, -5) == '.less') {
278-
$requestedPath = preg_replace('/.less$/', '.css', $filePath);
303+
$compiledFile = '';
304+
$extension = pathinfo($filePath, PATHINFO_EXTENSION);
305+
306+
foreach ($this->alternativeSources as $name => $alternative) {
307+
if (in_array($extension, $alternative->getAlternativesExtensionsNames(), true)
308+
&& strpos(basename($filePath), '_') !== 0
309+
) {
310+
$compiledFile = substr($filePath, 0, strlen($filePath) - strlen($extension) - 1);
311+
$compiledFile = $compiledFile . '.' . $name;
312+
}
279313
}
314+
280315
$logMessage = "Processing file '$filePath' for area '$area', theme '$themePath', locale '$locale'";
281316
if ($module) {
282317
$logMessage .= ", module '$module'";
@@ -288,7 +323,7 @@ private function deployFile($filePath, $area, $themePath, $locale, $module)
288323

289324
try {
290325
$asset = $this->assetRepo->createAsset(
291-
$requestedPath,
326+
$filePath,
292327
['area' => $area, 'theme' => $themePath, 'locale' => $locale, 'module' => $module]
293328
);
294329
if ($this->output->isVeryVerbose()) {
@@ -303,18 +338,13 @@ private function deployFile($filePath, $area, $themePath, $locale, $module)
303338
$this->bundleManager->addAsset($asset);
304339
}
305340
$this->count++;
306-
} catch (\Less_Exception_Compiler $e) {
307-
$this->verboseLog(
308-
"\tNotice: Could not parse LESS file '$filePath'. "
309-
. "This may indicate that the file is incomplete, but this is acceptable. "
310-
. "The file '$filePath' will be combined with another LESS file."
311-
);
312-
$this->verboseLog("\tCompiler error: " . $e->getMessage());
313341
} catch (\Exception $e) {
314-
$this->output->writeln($e->getMessage() . " ($logMessage)");
342+
$this->output->write('.');
315343
$this->verboseLog($e->getTraceAsString());
316344
$this->errorCount++;
317345
}
346+
347+
return $compiledFile;
318348
}
319349

320350
/**

app/code/Magento/Deploy/etc/di.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
9+
<type name="Magento\Deploy\Model\Deployer">
10+
<arguments>
11+
<argument name="alternativeSources" xsi:type="array">
12+
<item name="css" xsi:type="object">AlternativeSourceProcessors</item>
13+
</argument>
14+
</arguments>
15+
</type>
916
<type name="Magento\Framework\Console\CommandList">
1017
<arguments>
1118
<argument name="commands" xsi:type="array">

app/code/Magento/Developer/Console/Command/CssDeployCommand.php

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Magento\Developer\Console\Command;
88

9+
use Magento\Framework\View\Asset\PreProcessor\Pool;
910
use Symfony\Component\Console\Command\Command;
1011
use Symfony\Component\Console\Input\InputArgument;
1112
use Symfony\Component\Console\Input\InputOption;
@@ -17,7 +18,6 @@
1718
use Magento\Framework\View\Asset\Repository;
1819
use Magento\Framework\ObjectManagerInterface;
1920
use Magento\Framework\App\ObjectManager\ConfigLoader;
20-
use Magento\Framework\View\Asset\SourceFileGeneratorPool;
2121
use Magento\Framework\View\Asset\PreProcessor\ChainFactoryInterface;
2222
use Magento\Framework\App\Filesystem\DirectoryList;
2323
use Magento\Framework\Validator\Locale;
@@ -73,11 +73,6 @@ class CssDeployCommand extends Command
7373
*/
7474
private $state;
7575

76-
/**
77-
* @var SourceFileGeneratorPool
78-
*/
79-
private $sourceFileGeneratorPool;
80-
8176
/**
8277
* @var Source
8378
*/
@@ -98,6 +93,11 @@ class CssDeployCommand extends Command
9893
*/
9994
private $validator;
10095

96+
/**
97+
* @var Pool
98+
*/
99+
private $pool;
100+
101101
/**
102102
* Inject dependencies
103103
*
@@ -106,33 +106,33 @@ class CssDeployCommand extends Command
106106
* @param ConfigLoader $configLoader
107107
* @param State $state
108108
* @param Source $assetSource
109-
* @param SourceFileGeneratorPool $sourceFileGeneratorPoll
110109
* @param ChainFactoryInterface $chainFactory
111110
* @param Filesystem $filesystem
112111
* @param Locale $validator
112+
* @param Pool $pool
113113
*/
114114
public function __construct(
115115
ObjectManagerInterface $objectManager,
116116
Repository $assetRepo,
117117
ConfigLoader $configLoader,
118118
State $state,
119119
Source $assetSource,
120-
SourceFileGeneratorPool $sourceFileGeneratorPoll,
121120
ChainFactoryInterface $chainFactory,
122121
Filesystem $filesystem,
123-
Locale $validator
122+
Locale $validator,
123+
Pool $pool
124124
) {
125125
$this->state = $state;
126126
$this->objectManager = $objectManager;
127127
$this->configLoader = $configLoader;
128128
$this->assetRepo = $assetRepo;
129-
$this->sourceFileGeneratorPool = $sourceFileGeneratorPoll;
130129
$this->assetSource = $assetSource;
131130
$this->chainFactory = $chainFactory;
132131
$this->filesystem = $filesystem;
133132
$this->validator = $validator;
134133

135134
parent::__construct();
135+
$this->pool = $pool;
136136
}
137137

138138
/**
@@ -203,8 +203,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
203203
$this->state->setAreaCode($area);
204204
$this->objectManager->configure($this->configLoader->load($area));
205205

206-
$sourceFileGenerator = $this->sourceFileGeneratorPool->create($type);
207-
208206
foreach ($input->getArgument(self::FILE_ARGUMENT) as $file) {
209207
$file .= '.' . $type;
210208

@@ -233,14 +231,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
233231
]
234232
);
235233

236-
$processedCoreFile = $sourceFileGenerator->generateFileTree($chain);
237-
234+
$this->pool->process($chain);
238235
$targetDir = $this->filesystem->getDirectoryWrite(DirectoryList::STATIC_VIEW);
239-
$source = $rootDir->getRelativePath($processedCoreFile);
240-
$destination = $asset->getPath();
241-
$rootDir->copyFile($source, $destination, $targetDir);
236+
$targetDir->writeFile($chain->getAsset()->getPath(), $chain->getContent());
242237

243-
$output->writeln("<info>Successfully processed dynamic stylesheet into CSS</info>");
238+
$output->writeln('<info>Successfully processed dynamic stylesheet into CSS</info>');
244239
}
245240
}
246241
}

0 commit comments

Comments
 (0)