Skip to content

Commit d29bbeb

Browse files
author
Magento CICD
authored
merge magento/2.3-develop into magento-earl-grey/MAGETWO-92929
2 parents 4238b2e + 7f43369 commit d29bbeb

File tree

125 files changed

+2489
-604
lines changed

Some content is hidden

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

125 files changed

+2489
-604
lines changed

app/code/Magento/Backend/Block/Widget/Tabs.php

Lines changed: 94 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ public function addTab($tabId, $tab)
117117
if (empty($tabId)) {
118118
throw new \Exception(__('Please correct the tab configuration and try again. Tab Id should be not empty'));
119119
}
120+
120121
if (is_array($tab)) {
121122
$this->_tabs[$tabId] = new \Magento\Framework\DataObject($tab);
122123
} elseif ($tab instanceof \Magento\Framework\DataObject) {
@@ -126,13 +127,15 @@ public function addTab($tabId, $tab)
126127
}
127128
} elseif (is_string($tab)) {
128129
$this->_addTabByName($tab, $tabId);
130+
129131
if (!$this->_tabs[$tabId] instanceof TabInterface) {
130132
unset($this->_tabs[$tabId]);
131133
return $this;
132134
}
133135
} else {
134136
throw new \Exception(__('Please correct the tab configuration and try again.'));
135137
}
138+
136139
if ($this->_tabs[$tabId]->getUrl() === null) {
137140
$this->_tabs[$tabId]->setUrl('#');
138141
}
@@ -143,10 +146,7 @@ public function addTab($tabId, $tab)
143146

144147
$this->_tabs[$tabId]->setId($tabId);
145148
$this->_tabs[$tabId]->setTabId($tabId);
146-
147-
if ($this->_activeTab === null) {
148-
$this->_activeTab = $tabId;
149-
}
149+
150150
if (true === $this->_tabs[$tabId]->getActive()) {
151151
$this->setActiveTab($tabId);
152152
}
@@ -235,33 +235,108 @@ protected function _setActiveTab($tabId)
235235
*/
236236
protected function _beforeToHtml()
237237
{
238+
$this->_tabs = $this->reorderTabs();
239+
238240
if ($activeTab = $this->getRequest()->getParam('active_tab')) {
239241
$this->setActiveTab($activeTab);
240242
} elseif ($activeTabId = $this->_authSession->getActiveTabId()) {
241243
$this->_setActiveTab($activeTabId);
242244
}
243245

244-
$_new = [];
246+
if ($this->_activeTab === null && !empty($this->_tabs)) {
247+
/** @var TabInterface $tab */
248+
$this->_activeTab = (reset($this->_tabs))->getId();
249+
}
250+
251+
$this->assign('tabs', $this->_tabs);
252+
return parent::_beforeToHtml();
253+
}
254+
255+
/**
256+
* Reorder the tabs.
257+
*
258+
* @return array
259+
*/
260+
private function reorderTabs()
261+
{
262+
$orderByIdentity = [];
263+
$orderByPosition = [];
264+
$position = 100;
265+
266+
/**
267+
* Set the initial positions for each tab.
268+
*
269+
* @var string $key
270+
* @var TabInterface $tab
271+
*/
245272
foreach ($this->_tabs as $key => $tab) {
246-
foreach ($this->_tabs as $k => $t) {
247-
if ($t->getAfter() == $key) {
248-
$_new[$key] = $tab;
249-
$_new[$k] = $t;
250-
} else {
251-
if (!$tab->getAfter() || !in_array($tab->getAfter(), array_keys($this->_tabs))) {
252-
$_new[$key] = $tab;
253-
}
254-
}
255-
}
273+
$tab->setPosition($position);
274+
275+
$orderByIdentity[$key] = $tab;
276+
$orderByPosition[$position] = $tab;
277+
278+
$position += 100;
256279
}
257280

258-
$this->_tabs = $_new;
259-
unset($_new);
281+
return $this->applyTabsCorrectOrder($orderByPosition, $orderByIdentity);
282+
}
260283

261-
$this->assign('tabs', $this->_tabs);
262-
return parent::_beforeToHtml();
284+
/**
285+
* @param array $orderByPosition
286+
* @param array $orderByIdentity
287+
*
288+
* @return array
289+
*/
290+
private function applyTabsCorrectOrder(array $orderByPosition, array $orderByIdentity)
291+
{
292+
$positionFactor = 1;
293+
294+
/**
295+
* Rearrange the positions by using the after tag for each tab.
296+
*
297+
* @var integer $position
298+
* @var TabInterface $tab
299+
*/
300+
foreach ($orderByPosition as $position => $tab) {
301+
if (!$tab->getAfter() || !in_array($tab->getAfter(), array_keys($orderByIdentity))) {
302+
$positionFactor = 1;
303+
continue;
304+
}
305+
306+
$grandPosition = $orderByIdentity[$tab->getAfter()]->getPosition();
307+
$newPosition = $grandPosition + $positionFactor;
308+
309+
unset($orderByPosition[$position]);
310+
$orderByPosition[$newPosition] = $tab;
311+
$tab->setPosition($newPosition);
312+
313+
$positionFactor++;
314+
}
315+
316+
return $this->finalTabsSortOrder($orderByPosition);
263317
}
264318

319+
/**
320+
* Apply the last sort order to tabs.
321+
*
322+
* @param array $orderByPosition
323+
*
324+
* @return array
325+
*/
326+
private function finalTabsSortOrder(array $orderByPosition)
327+
{
328+
ksort($orderByPosition);
329+
330+
$ordered = [];
331+
332+
/** @var TabInterface $tab */
333+
foreach ($orderByPosition as $tab) {
334+
$ordered[$tab->getId()] = $tab;
335+
}
336+
337+
return $ordered;
338+
}
339+
265340
/**
266341
* @return string
267342
*/

app/code/Magento/Braintree/etc/adminhtml/system.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<comment>http://docs.magento.com/m2/ce/user_guide/payment/braintree.html</comment>
4545
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Hint</frontend_model>
4646
</group>
47-
<group id="braintree_required" translate="label" showInDefault="1" showInWebsite="1" sortOrder="5">
47+
<group id="braintree_required" translate="label" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="5">
4848
<label>Basic Braintree Settings</label>
4949
<attribute type="expanded">1</attribute>
5050
<frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
@@ -77,7 +77,7 @@
7777
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
7878
</field>
7979
</group>
80-
<group id="braintree_advanced" translate="label" showInDefault="1" showInWebsite="1" sortOrder="20">
80+
<group id="braintree_advanced" translate="label" showInDefault="1" showInWebsite="1" showInStore="0" sortOrder="20">
8181
<label>Advanced Braintree Settings</label>
8282
<frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
8383
<field id="braintree_cc_vault_title" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="0">
@@ -125,7 +125,7 @@
125125
<config_path>payment/braintree/sort_order</config_path>
126126
</field>
127127
</group>
128-
<group id="braintree_country_specific" translate="label" showInDefault="1" showInWebsite="1" sortOrder="30">
128+
<group id="braintree_country_specific" translate="label" showInDefault="1" showInWebsite="1" showInStore="0" sortOrder="30">
129129
<label>Country Specific Settings</label>
130130
<frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
131131
<field id="allowspecific" translate="label" type="allowspecific" sortOrder="200" showInDefault="1" showInWebsite="1" showInStore="0">
@@ -146,7 +146,7 @@
146146
<config_path>payment/braintree/countrycreditcard</config_path>
147147
</field>
148148
</group>
149-
<group id="braintree_paypal" translate="label" showInDefault="1" showInWebsite="1" sortOrder="40">
149+
<group id="braintree_paypal" translate="label" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="40">
150150
<label>PayPal through Braintree</label>
151151
<frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
152152
<field id="title" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
@@ -215,7 +215,7 @@
215215
<config_path>payment/braintree_paypal/skip_order_review</config_path>
216216
</field>
217217
</group>
218-
<group id="braintree_3dsecure" translate="label" showInDefault="1" showInWebsite="1" sortOrder="41">
218+
<group id="braintree_3dsecure" translate="label" showInDefault="1" showInWebsite="1" showInStore="0" sortOrder="41">
219219
<label>3D Secure Verification Settings</label>
220220
<frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
221221
<field id="verify_3dsecure" translate="label" type="select" sortOrder="150" showInDefault="1" showInWebsite="1" showInStore="0">
@@ -239,7 +239,7 @@
239239
<config_path>payment/braintree/verify_specific_countries</config_path>
240240
</field>
241241
</group>
242-
<group id="braintree_dynamic_descriptor" translate="label" showInDefault="1" showInWebsite="1" sortOrder="50">
242+
<group id="braintree_dynamic_descriptor" translate="label" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="50">
243243
<label>Dynamic Descriptors</label>
244244
<comment><![CDATA[Dynamic descriptors are sent on a per-transaction basis and define what will appear on your customers credit card statements for a specific purchase.
245245
The clearer the description of your product, the less likely customers will issue chargebacks due to confusion or non-recognition.

app/code/Magento/Captcha/Block/Captcha/DefaultCaptcha.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class DefaultCaptcha extends \Magento\Framework\View\Element\Template
1313
/**
1414
* @var string
1515
*/
16-
protected $_template = 'default.phtml';
16+
protected $_template = 'Magento_Captcha::default.phtml';
1717

1818
/**
1919
* @var string

app/code/Magento/Catalog/Api/ProductAttributeOptionManagementInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function getItems($attributeCode);
2929
* @param \Magento\Eav\Api\Data\AttributeOptionInterface $option
3030
* @throws \Magento\Framework\Exception\StateException
3131
* @throws \Magento\Framework\Exception\InputException
32-
* @return bool
32+
* @return string
3333
*/
3434
public function add($attributeCode, $option);
3535

app/code/Magento/Catalog/Block/Adminhtml/Category/AssignProducts.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class AssignProducts extends \Magento\Backend\Block\Template
1313
*
1414
* @var string
1515
*/
16-
protected $_template = 'catalog/category/edit/assign_products.phtml';
16+
protected $_template = 'Magento_Catalog::catalog/category/edit/assign_products.phtml';
1717

1818
/**
1919
* @var \Magento\Catalog\Block\Adminhtml\Category\Tab\Product

app/code/Magento/Catalog/Block/Adminhtml/Category/Tree.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Tree extends \Magento\Catalog\Block\Adminhtml\Category\AbstractCategory
2727
/**
2828
* @var string
2929
*/
30-
protected $_template = 'catalog/category/tree.phtml';
30+
protected $_template = 'Magento_Catalog::catalog/category/tree.phtml';
3131

3232
/**
3333
* @var \Magento\Backend\Model\Auth\Session

app/code/Magento/Catalog/Block/Adminhtml/Category/Widget/Chooser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Chooser extends \Magento\Catalog\Block\Adminhtml\Category\Tree
2424
*
2525
* @var string
2626
*/
27-
protected $_template = 'catalog/category/widget/tree.phtml';
27+
protected $_template = 'Magento_Catalog::catalog/category/widget/tree.phtml';
2828

2929
/**
3030
* @return void

app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Main extends \Magento\Backend\Block\Template
2222
/**
2323
* @var string
2424
*/
25-
protected $_template = 'catalog/product/attribute/set/main.phtml';
25+
protected $_template = 'Magento_Catalog::catalog/product/attribute/set/main.phtml';
2626

2727
/**
2828
* Core registry

app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main/Tree/Group.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ class Group extends \Magento\Backend\Block\Template
1414
/**
1515
* @var string
1616
*/
17-
protected $_template = 'catalog/product/attribute/set/main/tree/group.phtml';
17+
protected $_template = 'Magento_Catalog::catalog/product/attribute/set/main/tree/group.phtml';
1818
}

app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Toolbar/Add.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Add extends \Magento\Backend\Block\Template
1818
/**
1919
* @var string
2020
*/
21-
protected $_template = 'catalog/product/attribute/set/toolbar/add.phtml';
21+
protected $_template = 'Magento_Catalog::catalog/product/attribute/set/toolbar/add.phtml';
2222

2323
/**
2424
* @return AbstractBlock

0 commit comments

Comments
 (0)