Skip to content

Commit 63299a7

Browse files
committed
Merge remote-tracking branch 'upstream/2.3-develop' into 2.3.0-release-sync2
2 parents 2c9a9e5 + 708017a commit 63299a7

File tree

86 files changed

+2223
-614
lines changed

Some content is hidden

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

86 files changed

+2223
-614
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,20 @@
55
- Information on your environment,
66
- Steps to reproduce,
77
- Expected and actual results,
8+
Fields marked with (*) are required. Please don't remove the template.
89
910
Please also have a look at our guidelines article before adding a new issue https://github.com/magento/magento2/wiki/Issue-reporting-guidelines
1011
-->
1112

12-
### Preconditions
13+
### Preconditions (*)
1314
<!---
1415
Please provide as detailed information about your environment as possible.
1516
For example Magento version, tag, HEAD, PHP & MySQL version, etc..
1617
-->
1718
1.
1819
2.
1920

20-
### Steps to reproduce
21+
### Steps to reproduce (*)
2122
<!---
2223
It is important to provide a set of clear steps to reproduce this bug.
2324
If relevant please include code samples
@@ -26,10 +27,10 @@
2627
2.
2728
3.
2829

29-
### Expected result
30+
### Expected result (*)
3031
<!--- Tell us what should happen -->
3132
1. [Screenshots, logs or description]
3233

33-
### Actual result
34+
### Actual result (*)
3435
<!--- Tell us what happens instead -->
3536
1. [Screenshots, logs or description]

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,29 @@ about: Technical issue with the Magento 2 core components
66

77
<!---
88
Please review our guidelines before adding a new issue: https://github.com/magento/magento2/wiki/Issue-reporting-guidelines
9+
Fields marked with (*) are required. Please don't remove the template.
910
-->
1011

11-
### Preconditions
12+
### Preconditions (*)
1213
<!---
1314
Provide the exact Magento version (example: 2.2.5) and any important information on the environment where bug is reproducible.
1415
-->
1516
1.
1617
2.
1718

18-
### Steps to reproduce
19+
### Steps to reproduce (*)
1920
<!---
2021
Important: Provide a set of clear steps to reproduce this bug. We can not provide support without clear instructions on how to reproduce.
2122
-->
2223
1.
2324
2.
2425

25-
### Expected result
26+
### Expected result (*)
2627
<!--- Tell us what do you expect to happen. -->
2728
1. [Screenshots, logs or description]
2829
2.
2930

30-
### Actual result
31+
### Actual result (*)
3132
<!--- Tell us what happened instead. Include error messages and issues. -->
3233
1. [Screenshots, logs or description]
3334
2.

.github/ISSUE_TEMPLATE/developer-experience-issue.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ about: Issues related to customization, extensibility, modularity
66

77
<!---
88
Please review our guidelines before adding a new issue: https://github.com/magento/magento2/wiki/Issue-reporting-guidelines
9+
Fields marked with (*) are required. Please don't remove the template.
910
-->
1011

11-
### Summary
12+
### Summary (*)
1213
<!--- Describe the issue you are experiencing. Include general information, error messages, environments, and so on. -->
1314

14-
### Examples
15+
### Examples (*)
1516
<!--- Provide code examples or a patch with a test (recommended) to clearly indicate the problem. -->
1617

1718
### Proposed solution

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ about: Please consider reporting directly to https://github.com/magento/communit
55
---
66

77
<!---
8-
Important: This repository is intended only for Magento 2 Technical Issues. Enter Feature Requests at https://github.com/magento/community-features. Project stakeholders monitor and manage requests. Feature requests entered using this form may be moved to the forum.
8+
Important: This repository is intended only for Magento 2 Technical Issues. Enter Feature Requests at https://github.com/magento/community-features. Project stakeholders monitor and manage requests. Feature requests entered using this form may be moved to the forum. Fields marked with (*) are required. Please don't remove the template.
99
-->
1010

11-
### Description
11+
### Description (*)
1212
<!--- Describe the feature you would like to add. -->
1313

14-
### Expected behavior
14+
### Expected behavior (*)
1515
<!--- What is the expected behavior of this feature? How is it going to work? -->
1616

1717
### Benefits

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
To help us process this pull request we recommend that you add the following information:
44
- Summary of the pull request,
55
- Issue(s) related to the changes made,
6-
- Manual testing scenarios,
6+
- Manual testing scenarios
7+
Fields marked with (*) are required. Please don't remove the template.
78
-->
89

910
<!--- Please provide a general summary of the Pull Request in the Title above -->
1011

11-
### Description
12+
### Description (*)
1213
<!---
1314
Please provide a description of the changes proposed in the pull request.
1415
Letting us know what has changed and why it needed changing will help us validate this pull request.
@@ -22,15 +23,15 @@
2223
1. magento/magento2#<issue_number>: Issue title
2324
2. ...
2425

25-
### Manual testing scenarios
26+
### Manual testing scenarios (*)
2627
<!---
2728
Please provide a set of unambiguous steps to test the proposed code change.
2829
Giving us manual testing scenarios will help with the processing and validation process.
2930
-->
3031
1. ...
3132
2. ...
3233

33-
### Contribution checklist
34+
### Contribution checklist (*)
3435
- [ ] Pull request has a meaningful description of its purpose
3536
- [ ] All commits are accompanied by meaningful commit messages
3637
- [ ] All new or changed code is covered with unit/integration tests (if applicable)

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
[![Build Status](https://travis-ci.org/magento/magento2.svg?branch=2.3-develop)](https://travis-ci.org/magento/magento2)
22
[![Open Source Helpers](https://www.codetriage.com/magento/magento2/badges/users.svg)](https://www.codetriage.com/magento/magento2)
33
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/magento/magento2?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
4-
[![Crowdin](https://d322cqt584bo4o.cloudfront.net/magento-2/localized.png)](https://crowdin.com/project/magento-2)
4+
[![Crowdin](https://d322cqt584bo4o.cloudfront.net/magento-2/localized.svg)](https://crowdin.com/project/magento-2)
55
<h2>Welcome</h2>
66
Welcome to Magento 2 installation! We're glad you chose to install Magento 2, a cutting-edge, feature-rich eCommerce solution that gets results.
77

88
## Magento system requirements
9-
[Magento system requirements](http://devdocs.magento.com/guides/v2.3/install-gde/system-requirements2.html)
9+
[Magento system requirements](http://devdocs.magento.com/guides/v2.3/install-gde/system-requirements2.html).
1010

1111
## Install Magento
12-
To install Magento, see either:
1312

14-
* [Installation guide](http://devdocs.magento.com/guides/v2.3/install-gde/bk-install-guide.html)
13+
* [Installation guide](http://devdocs.magento.com/guides/v2.3/install-gde/bk-install-guide.html).
1514

1615
<h2>Contributing to the Magento 2 code base</h2>
1716
Contributions can take the form of new components or features, changes to existing features, tests, documentation (such as developer guides, user guides, examples, or specifications), bug fixes, optimizations, or just good suggestions.
@@ -52,7 +51,7 @@ Stay up-to-date on the latest security news and patches for Magento by signing u
5251

5352
<h2>License</h2>
5453

55-
Each Magento source file included in this distribution is licensed under OSL 3.0 or the Magento Enterprise Edition (MEE) license
54+
Each Magento source file included in this distribution is licensed under OSL 3.0 or the Magento Enterprise Edition (MEE) license.
5655

5756
http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
5857
Please see LICENSE.txt for the full text of the OSL 3.0 license or contact license@magentocommerce.com for a copy.

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

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
67
namespace Magento\Backend\Block\Widget;
78

9+
use Magento\Framework\App\ObjectManager;
10+
811
/**
912
* Backend form widget
1013
*
@@ -27,13 +30,23 @@ class Form extends \Magento\Backend\Block\Widget
2730
*/
2831
protected $_template = 'Magento_Backend::widget/form.phtml';
2932

33+
/** @var Form\Element\ElementCreator */
34+
private $creator;
35+
3036
/**
37+
* Constructs form
38+
*
3139
* @param \Magento\Backend\Block\Template\Context $context
3240
* @param array $data
41+
* @param Form\Element\ElementCreator|null $creator
3342
*/
34-
public function __construct(\Magento\Backend\Block\Template\Context $context, array $data = [])
35-
{
43+
public function __construct(
44+
\Magento\Backend\Block\Template\Context $context,
45+
array $data = [],
46+
Form\Element\ElementCreator $creator = null
47+
) {
3648
parent::__construct($context, $data);
49+
$this->creator = $creator ?: ObjectManager::getInstance()->get(Form\Element\ElementCreator::class);
3750
}
3851

3952
/**
@@ -148,6 +161,7 @@ protected function _beforeToHtml()
148161

149162
/**
150163
* Initialize form fields values
164+
*
151165
* Method will be called after prepareForm and can be used for field values initialization
152166
*
153167
* @return $this
@@ -173,32 +187,11 @@ protected function _setFieldset($attributes, $fieldset, $exclude = [])
173187
if (!$this->_isAttributeVisible($attribute)) {
174188
continue;
175189
}
176-
if (($inputType = $attribute->getFrontend()->getInputType()) && !in_array(
177-
$attribute->getAttributeCode(),
178-
$exclude
179-
) && ('media_image' != $inputType || $attribute->getAttributeCode() == 'image')
190+
if (($inputType = $attribute->getFrontend()->getInputType())
191+
&& !in_array($attribute->getAttributeCode(), $exclude)
192+
&& ('media_image' !== $inputType || $attribute->getAttributeCode() == 'image')
180193
) {
181-
$fieldType = $inputType;
182-
$rendererClass = $attribute->getFrontend()->getInputRendererClass();
183-
if (!empty($rendererClass)) {
184-
$fieldType = $inputType . '_' . $attribute->getAttributeCode();
185-
$fieldset->addType($fieldType, $rendererClass);
186-
}
187-
188-
$element = $fieldset->addField(
189-
$attribute->getAttributeCode(),
190-
$fieldType,
191-
[
192-
'name' => $attribute->getAttributeCode(),
193-
'label' => $attribute->getFrontend()->getLocalizedLabel(),
194-
'class' => $attribute->getFrontend()->getClass(),
195-
'required' => $attribute->getIsRequired(),
196-
'note' => $attribute->getNote()
197-
]
198-
)->setEntityAttribute(
199-
$attribute
200-
);
201-
194+
$element = $this->creator->create($fieldset, $attribute);
202195
$element->setAfterElementHtml($this->_getAdditionalElementHtml($element));
203196

204197
$this->_applyTypeSpecificConfig($inputType, $element, $attribute);
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Backend\Block\Widget\Form\Element;
9+
10+
use Magento\Eav\Model\Entity\Attribute;
11+
use Magento\Framework\Data\Form\Element\AbstractElement;
12+
use Magento\Framework\Data\Form\Element\Fieldset;
13+
14+
/**
15+
* Class ElementCreator
16+
*
17+
* @deprecated 100.3.0 in favour of UI component implementation
18+
* @package Magento\Backend\Block\Widget\Form\Element
19+
*/
20+
class ElementCreator
21+
{
22+
/**
23+
* @var array
24+
*/
25+
private $modifiers;
26+
27+
/**
28+
* ElementCreator constructor.
29+
*
30+
* @param array $modifiers
31+
*/
32+
public function __construct(array $modifiers = [])
33+
{
34+
$this->modifiers = $modifiers;
35+
}
36+
37+
/**
38+
* Creates element
39+
*
40+
* @param Fieldset $fieldset
41+
* @param Attribute $attribute
42+
*
43+
* @return AbstractElement
44+
*/
45+
public function create(Fieldset $fieldset, Attribute $attribute): AbstractElement
46+
{
47+
$config = $this->getElementConfig($attribute);
48+
49+
if (!empty($config['rendererClass'])) {
50+
$fieldType = $config['inputType'] . '_' . $attribute->getAttributeCode();
51+
$fieldset->addType($fieldType, $config['rendererClass']);
52+
}
53+
54+
return $fieldset
55+
->addField($config['attribute_code'], $config['inputType'], $config)
56+
->setEntityAttribute($attribute);
57+
}
58+
59+
/**
60+
* Returns element config
61+
*
62+
* @param Attribute $attribute
63+
* @return array
64+
*/
65+
private function getElementConfig(Attribute $attribute): array
66+
{
67+
$defaultConfig = $this->createDefaultConfig($attribute);
68+
$config = $this->modifyConfig($defaultConfig);
69+
70+
$config['label'] = __($config['label']);
71+
72+
return $config;
73+
}
74+
75+
/**
76+
* Returns default config
77+
*
78+
* @param Attribute $attribute
79+
* @return array
80+
*/
81+
private function createDefaultConfig(Attribute $attribute): array
82+
{
83+
return [
84+
'inputType' => $attribute->getFrontend()->getInputType(),
85+
'rendererClass' => $attribute->getFrontend()->getInputRendererClass(),
86+
'attribute_code' => $attribute->getAttributeCode(),
87+
'name' => $attribute->getAttributeCode(),
88+
'label' => $attribute->getFrontend()->getLabel(),
89+
'class' => $attribute->getFrontend()->getClass(),
90+
'required' => $attribute->getIsRequired(),
91+
'note' => $attribute->getNote(),
92+
];
93+
}
94+
95+
/**
96+
* Modify config
97+
*
98+
* @param array $config
99+
* @return array
100+
*/
101+
private function modifyConfig(array $config): array
102+
{
103+
if ($this->isModified($config['attribute_code'])) {
104+
return $this->applyModifier($config);
105+
}
106+
return $config;
107+
}
108+
109+
/**
110+
* Returns bool if attribute need to modify
111+
*
112+
* @param string $attribute_code
113+
* @return bool
114+
*/
115+
private function isModified($attribute_code): bool
116+
{
117+
return isset($this->modifiers[$attribute_code]);
118+
}
119+
120+
/**
121+
* Apply modifier to config
122+
*
123+
* @param array $config
124+
* @return array
125+
*/
126+
private function applyModifier(array $config): array
127+
{
128+
$modifiedConfig = $this->modifiers[$config['attribute_code']];
129+
foreach (array_keys($config) as $key) {
130+
if (isset($modifiedConfig[$key])) {
131+
$config[$key] = $modifiedConfig[$key];
132+
}
133+
}
134+
return $config;
135+
}
136+
}

0 commit comments

Comments
 (0)