Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 301d73d

Browse files
authored
Merge pull request #2 from magento/2.2-develop
2.2 develop-update
2 parents c9d1bec + 8648f52 commit 301d73d

File tree

305 files changed

+5996
-1216
lines changed

Some content is hidden

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

305 files changed

+5996
-1216
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)

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
<source_model>Magento\Analytics\Model\Config\Source\Vertical</source_model>
3737
<backend_model>Magento\Analytics\Model\Config\Backend\Vertical</backend_model>
3838
<frontend_model>Magento\Analytics\Block\Adminhtml\System\Config\Vertical</frontend_model>
39+
<depends>
40+
<field id="analytics/general/enabled">1</field>
41+
</depends>
3942
</field>
4043
<field id="additional_comment" translate="label comment" type="label" sortOrder="40" showInDefault="1" showInWebsite="0" showInStore="0">
4144
<label><![CDATA[<strong>Get more insights from Magento Business Intelligence</strong>]]></label>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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\DataProviders;
9+
10+
use Magento\Framework\View\Element\Block\ArgumentInterface;
11+
12+
/**
13+
* Provides additional data for image uploader
14+
*/
15+
class UploadConfig implements ArgumentInterface
16+
{
17+
/**
18+
* @var \Magento\Framework\App\Config\ScopeConfigInterface
19+
*/
20+
private $config;
21+
22+
/**
23+
* @param \Magento\Framework\App\Config\ScopeConfigInterface $config
24+
*/
25+
public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $config)
26+
{
27+
$this->config = $config;
28+
}
29+
30+
/**
31+
* Get image resize configuration
32+
*
33+
* @return int
34+
*/
35+
public function getIsResizeEnabled(): int
36+
{
37+
return (int)$this->config->getValue('system/upload_configuration/enable_resize');
38+
}
39+
}

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

Lines changed: 51 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,20 @@
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\Backend\Block\Widget\Form\Element\ElementCreator;
10+
use Magento\Framework\App\ObjectManager;
11+
use Magento\Backend\Block\Template\Context;
12+
use Magento\Framework\Data\Form as DataForm;
13+
use Magento\Backend\Block\Widget\Form\Renderer\Element;
14+
use Magento\Backend\Block\Widget\Form\Renderer\Fieldset;
15+
use Magento\Backend\Block\Widget\Form\Renderer\Fieldset\Element as FieldsetElement;
16+
use Magento\Eav\Model\Entity\Attribute;
17+
use Magento\Framework\Data\Form\Element\AbstractElement;
18+
use Magento\Framework\Data\Form\AbstractForm;
19+
820
/**
921
* Backend form widget
1022
*
@@ -18,7 +30,7 @@ class Form extends \Magento\Backend\Block\Widget
1830
/**
1931
* Form Object
2032
*
21-
* @var \Magento\Framework\Data\Form
33+
* @var DataForm
2234
*/
2335
protected $_form;
2436

@@ -28,12 +40,24 @@ class Form extends \Magento\Backend\Block\Widget
2840
protected $_template = 'Magento_Backend::widget/form.phtml';
2941

3042
/**
31-
* @param \Magento\Backend\Block\Template\Context $context
43+
* @var ElementCreator
44+
* /
45+
private $creator;
46+
47+
/**
48+
* Constructs form
49+
*
50+
* @param Context $context
3251
* @param array $data
52+
* @param ElementCreator|null $creator
3353
*/
34-
public function __construct(\Magento\Backend\Block\Template\Context $context, array $data = [])
35-
{
54+
public function __construct(
55+
Context $context,
56+
array $data = [],
57+
ElementCreator $creator = null
58+
) {
3659
parent::__construct($context, $data);
60+
$this->creator = $creator ?: ObjectManager::getInstance()->get(ElementCreator::class);
3761
}
3862

3963
/**
@@ -58,21 +82,21 @@ protected function _construct()
5882
*/
5983
protected function _prepareLayout()
6084
{
61-
\Magento\Framework\Data\Form::setElementRenderer(
85+
DataForm::setElementRenderer(
6286
$this->getLayout()->createBlock(
63-
\Magento\Backend\Block\Widget\Form\Renderer\Element::class,
87+
Element::class,
6488
$this->getNameInLayout() . '_element'
6589
)
6690
);
67-
\Magento\Framework\Data\Form::setFieldsetRenderer(
91+
DataForm::setFieldsetRenderer(
6892
$this->getLayout()->createBlock(
69-
\Magento\Backend\Block\Widget\Form\Renderer\Fieldset::class,
93+
Fieldset::class,
7094
$this->getNameInLayout() . '_fieldset'
7195
)
7296
);
73-
\Magento\Framework\Data\Form::setFieldsetElementRenderer(
97+
DataForm::setFieldsetElementRenderer(
7498
$this->getLayout()->createBlock(
75-
\Magento\Backend\Block\Widget\Form\Renderer\Fieldset\Element::class,
99+
FieldsetElement::class,
76100
$this->getNameInLayout() . '_fieldset_element'
77101
)
78102
);
@@ -83,7 +107,7 @@ protected function _prepareLayout()
83107
/**
84108
* Get form object
85109
*
86-
* @return \Magento\Framework\Data\Form
110+
* @return DataForm
87111
*/
88112
public function getForm()
89113
{
@@ -106,10 +130,10 @@ public function getFormHtml()
106130
/**
107131
* Set form object
108132
*
109-
* @param \Magento\Framework\Data\Form $form
133+
* @param DataForm $form
110134
* @return $this
111135
*/
112-
public function setForm(\Magento\Framework\Data\Form $form)
136+
public function setForm(DataForm $form)
113137
{
114138
$this->_form = $form;
115139
$this->_form->setParent($this);
@@ -148,6 +172,7 @@ protected function _beforeToHtml()
148172

149173
/**
150174
* Initialize form fields values
175+
*
151176
* Method will be called after prepareForm and can be used for field values initialization
152177
*
153178
* @return $this
@@ -169,36 +194,15 @@ protected function _setFieldset($attributes, $fieldset, $exclude = [])
169194
{
170195
$this->_addElementTypes($fieldset);
171196
foreach ($attributes as $attribute) {
172-
/* @var $attribute \Magento\Eav\Model\Entity\Attribute */
197+
/* @var $attribute Attribute */
173198
if (!$this->_isAttributeVisible($attribute)) {
174199
continue;
175200
}
176-
if (($inputType = $attribute->getFrontend()->getInputType()) && !in_array(
177-
$attribute->getAttributeCode(),
178-
$exclude
179-
) && ('media_image' != $inputType || $attribute->getAttributeCode() == 'image')
201+
if (($inputType = $attribute->getFrontend()->getInputType())
202+
&& !in_array($attribute->getAttributeCode(), $exclude)
203+
&& ('media_image' !== $inputType || $attribute->getAttributeCode() == 'image')
180204
) {
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-
205+
$element = $this->creator->create($fieldset, $attribute);
202206
$element->setAfterElementHtml($this->_getAdditionalElementHtml($element));
203207

204208
$this->_applyTypeSpecificConfig($inputType, $element, $attribute);
@@ -209,10 +213,10 @@ protected function _setFieldset($attributes, $fieldset, $exclude = [])
209213
/**
210214
* Check whether attribute is visible
211215
*
212-
* @param \Magento\Eav\Model\Entity\Attribute $attribute
216+
* @param Attribute $attribute
213217
* @return bool
214218
*/
215-
protected function _isAttributeVisible(\Magento\Eav\Model\Entity\Attribute $attribute)
219+
protected function _isAttributeVisible(Attribute $attribute)
216220
{
217221
return !(!$attribute || $attribute->hasIsVisible() && !$attribute->getIsVisible());
218222
}
@@ -221,11 +225,11 @@ protected function _isAttributeVisible(\Magento\Eav\Model\Entity\Attribute $attr
221225
* Apply configuration specific for different element type
222226
*
223227
* @param string $inputType
224-
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
225-
* @param \Magento\Eav\Model\Entity\Attribute $attribute
228+
* @param AbstractElement $element
229+
* @param Attribute $attribute
226230
* @return void
227231
*/
228-
protected function _applyTypeSpecificConfig($inputType, $element, \Magento\Eav\Model\Entity\Attribute $attribute)
232+
protected function _applyTypeSpecificConfig($inputType, $element, Attribute $attribute)
229233
{
230234
switch ($inputType) {
231235
case 'select':
@@ -249,10 +253,10 @@ protected function _applyTypeSpecificConfig($inputType, $element, \Magento\Eav\M
249253
/**
250254
* Add new element type
251255
*
252-
* @param \Magento\Framework\Data\Form\AbstractForm $baseElement
256+
* @param AbstractForm $baseElement
253257
* @return void
254258
*/
255-
protected function _addElementTypes(\Magento\Framework\Data\Form\AbstractForm $baseElement)
259+
protected function _addElementTypes(AbstractForm $baseElement)
256260
{
257261
$types = $this->_getAdditionalElementTypes();
258262
foreach ($types as $code => $className) {
@@ -273,7 +277,7 @@ protected function _getAdditionalElementTypes()
273277
/**
274278
* Render additional element
275279
*
276-
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
280+
* @param AbstractElement $element
277281
* @return string
278282
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
279283
*/

0 commit comments

Comments
 (0)