Skip to content

Commit

Permalink
Merge pull request #2 from magento/2.2-develop
Browse files Browse the repository at this point in the history
2.2 develop-update
  • Loading branch information
speedy008 authored Nov 3, 2018
2 parents c9d1bec + 8648f52 commit 301d73d
Show file tree
Hide file tree
Showing 305 changed files with 5,996 additions and 1,216 deletions.
9 changes: 5 additions & 4 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@
- Information on your environment,
- Steps to reproduce,
- Expected and actual results,
Fields marked with (*) are required. Please don't remove the template.
Please also have a look at our guidelines article before adding a new issue https://github.com/magento/magento2/wiki/Issue-reporting-guidelines
-->

### Preconditions
### Preconditions (*)
<!---
Please provide as detailed information about your environment as possible.
For example Magento version, tag, HEAD, PHP & MySQL version, etc..
-->
1.
2.

### Steps to reproduce
### Steps to reproduce (*)
<!---
It is important to provide a set of clear steps to reproduce this bug.
If relevant please include code samples
Expand All @@ -26,10 +27,10 @@
2.
3.

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

### Actual result
### Actual result (*)
<!--- Tell us what happens instead -->
1. [Screenshots, logs or description]
9 changes: 5 additions & 4 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,29 @@ about: Technical issue with the Magento 2 core components

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

### Preconditions
### Preconditions (*)
<!---
Provide the exact Magento version (example: 2.2.5) and any important information on the environment where bug is reproducible.
-->
1.
2.

### Steps to reproduce
### Steps to reproduce (*)
<!---
Important: Provide a set of clear steps to reproduce this bug. We can not provide support without clear instructions on how to reproduce.
-->
1.
2.

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

### Actual result
### Actual result (*)
<!--- Tell us what happened instead. Include error messages and issues. -->
1. [Screenshots, logs or description]
2.
5 changes: 3 additions & 2 deletions .github/ISSUE_TEMPLATE/developer-experience-issue.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ about: Issues related to customization, extensibility, modularity

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

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

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

### Proposed solution
Expand Down
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ about: Please consider reporting directly to https://github.com/magento/communit
---

<!---
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.
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.
-->

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

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

### Benefits
Expand Down
9 changes: 5 additions & 4 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
To help us process this pull request we recommend that you add the following information:
- Summary of the pull request,
- Issue(s) related to the changes made,
- Manual testing scenarios,
- Manual testing scenarios
Fields marked with (*) are required. Please don't remove the template.
-->

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

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

### Manual testing scenarios
### Manual testing scenarios (*)
<!---
Please provide a set of unambiguous steps to test the proposed code change.
Giving us manual testing scenarios will help with the processing and validation process.
-->
1. ...
2. ...

### Contribution checklist
### Contribution checklist (*)
- [ ] Pull request has a meaningful description of its purpose
- [ ] All commits are accompanied by meaningful commit messages
- [ ] All new or changed code is covered with unit/integration tests (if applicable)
Expand Down
3 changes: 3 additions & 0 deletions app/code/Magento/Analytics/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
<source_model>Magento\Analytics\Model\Config\Source\Vertical</source_model>
<backend_model>Magento\Analytics\Model\Config\Backend\Vertical</backend_model>
<frontend_model>Magento\Analytics\Block\Adminhtml\System\Config\Vertical</frontend_model>
<depends>
<field id="analytics/general/enabled">1</field>
</depends>
</field>
<field id="additional_comment" translate="label comment" type="label" sortOrder="40" showInDefault="1" showInWebsite="0" showInStore="0">
<label><![CDATA[<strong>Get more insights from Magento Business Intelligence</strong>]]></label>
Expand Down
39 changes: 39 additions & 0 deletions app/code/Magento/Backend/Block/DataProviders/UploadConfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Backend\Block\DataProviders;

use Magento\Framework\View\Element\Block\ArgumentInterface;

/**
* Provides additional data for image uploader
*/
class UploadConfig implements ArgumentInterface
{
/**
* @var \Magento\Framework\App\Config\ScopeConfigInterface
*/
private $config;

/**
* @param \Magento\Framework\App\Config\ScopeConfigInterface $config
*/
public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $config)
{
$this->config = $config;
}

/**
* Get image resize configuration
*
* @return int
*/
public function getIsResizeEnabled(): int
{
return (int)$this->config->getValue('system/upload_configuration/enable_resize');
}
}
98 changes: 51 additions & 47 deletions app/code/Magento/Backend/Block/Widget/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,20 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Backend\Block\Widget;

use Magento\Backend\Block\Widget\Form\Element\ElementCreator;
use Magento\Framework\App\ObjectManager;
use Magento\Backend\Block\Template\Context;
use Magento\Framework\Data\Form as DataForm;
use Magento\Backend\Block\Widget\Form\Renderer\Element;
use Magento\Backend\Block\Widget\Form\Renderer\Fieldset;
use Magento\Backend\Block\Widget\Form\Renderer\Fieldset\Element as FieldsetElement;
use Magento\Eav\Model\Entity\Attribute;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\Data\Form\AbstractForm;

/**
* Backend form widget
*
Expand All @@ -18,7 +30,7 @@ class Form extends \Magento\Backend\Block\Widget
/**
* Form Object
*
* @var \Magento\Framework\Data\Form
* @var DataForm
*/
protected $_form;

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

/**
* @param \Magento\Backend\Block\Template\Context $context
* @var ElementCreator
* /
private $creator;
/**
* Constructs form
*
* @param Context $context
* @param array $data
* @param ElementCreator|null $creator
*/
public function __construct(\Magento\Backend\Block\Template\Context $context, array $data = [])
{
public function __construct(
Context $context,
array $data = [],
ElementCreator $creator = null
) {
parent::__construct($context, $data);
$this->creator = $creator ?: ObjectManager::getInstance()->get(ElementCreator::class);
}

/**
Expand All @@ -58,21 +82,21 @@ protected function _construct()
*/
protected function _prepareLayout()
{
\Magento\Framework\Data\Form::setElementRenderer(
DataForm::setElementRenderer(
$this->getLayout()->createBlock(
\Magento\Backend\Block\Widget\Form\Renderer\Element::class,
Element::class,
$this->getNameInLayout() . '_element'
)
);
\Magento\Framework\Data\Form::setFieldsetRenderer(
DataForm::setFieldsetRenderer(
$this->getLayout()->createBlock(
\Magento\Backend\Block\Widget\Form\Renderer\Fieldset::class,
Fieldset::class,
$this->getNameInLayout() . '_fieldset'
)
);
\Magento\Framework\Data\Form::setFieldsetElementRenderer(
DataForm::setFieldsetElementRenderer(
$this->getLayout()->createBlock(
\Magento\Backend\Block\Widget\Form\Renderer\Fieldset\Element::class,
FieldsetElement::class,
$this->getNameInLayout() . '_fieldset_element'
)
);
Expand All @@ -83,7 +107,7 @@ protected function _prepareLayout()
/**
* Get form object
*
* @return \Magento\Framework\Data\Form
* @return DataForm
*/
public function getForm()
{
Expand All @@ -106,10 +130,10 @@ public function getFormHtml()
/**
* Set form object
*
* @param \Magento\Framework\Data\Form $form
* @param DataForm $form
* @return $this
*/
public function setForm(\Magento\Framework\Data\Form $form)
public function setForm(DataForm $form)
{
$this->_form = $form;
$this->_form->setParent($this);
Expand Down Expand Up @@ -148,6 +172,7 @@ protected function _beforeToHtml()

/**
* Initialize form fields values
*
* Method will be called after prepareForm and can be used for field values initialization
*
* @return $this
Expand All @@ -169,36 +194,15 @@ protected function _setFieldset($attributes, $fieldset, $exclude = [])
{
$this->_addElementTypes($fieldset);
foreach ($attributes as $attribute) {
/* @var $attribute \Magento\Eav\Model\Entity\Attribute */
/* @var $attribute Attribute */
if (!$this->_isAttributeVisible($attribute)) {
continue;
}
if (($inputType = $attribute->getFrontend()->getInputType()) && !in_array(
$attribute->getAttributeCode(),
$exclude
) && ('media_image' != $inputType || $attribute->getAttributeCode() == 'image')
if (($inputType = $attribute->getFrontend()->getInputType())
&& !in_array($attribute->getAttributeCode(), $exclude)
&& ('media_image' !== $inputType || $attribute->getAttributeCode() == 'image')
) {
$fieldType = $inputType;
$rendererClass = $attribute->getFrontend()->getInputRendererClass();
if (!empty($rendererClass)) {
$fieldType = $inputType . '_' . $attribute->getAttributeCode();
$fieldset->addType($fieldType, $rendererClass);
}

$element = $fieldset->addField(
$attribute->getAttributeCode(),
$fieldType,
[
'name' => $attribute->getAttributeCode(),
'label' => $attribute->getFrontend()->getLocalizedLabel(),
'class' => $attribute->getFrontend()->getClass(),
'required' => $attribute->getIsRequired(),
'note' => $attribute->getNote()
]
)->setEntityAttribute(
$attribute
);

$element = $this->creator->create($fieldset, $attribute);
$element->setAfterElementHtml($this->_getAdditionalElementHtml($element));

$this->_applyTypeSpecificConfig($inputType, $element, $attribute);
Expand All @@ -209,10 +213,10 @@ protected function _setFieldset($attributes, $fieldset, $exclude = [])
/**
* Check whether attribute is visible
*
* @param \Magento\Eav\Model\Entity\Attribute $attribute
* @param Attribute $attribute
* @return bool
*/
protected function _isAttributeVisible(\Magento\Eav\Model\Entity\Attribute $attribute)
protected function _isAttributeVisible(Attribute $attribute)
{
return !(!$attribute || $attribute->hasIsVisible() && !$attribute->getIsVisible());
}
Expand All @@ -221,11 +225,11 @@ protected function _isAttributeVisible(\Magento\Eav\Model\Entity\Attribute $attr
* Apply configuration specific for different element type
*
* @param string $inputType
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @param \Magento\Eav\Model\Entity\Attribute $attribute
* @param AbstractElement $element
* @param Attribute $attribute
* @return void
*/
protected function _applyTypeSpecificConfig($inputType, $element, \Magento\Eav\Model\Entity\Attribute $attribute)
protected function _applyTypeSpecificConfig($inputType, $element, Attribute $attribute)
{
switch ($inputType) {
case 'select':
Expand All @@ -249,10 +253,10 @@ protected function _applyTypeSpecificConfig($inputType, $element, \Magento\Eav\M
/**
* Add new element type
*
* @param \Magento\Framework\Data\Form\AbstractForm $baseElement
* @param AbstractForm $baseElement
* @return void
*/
protected function _addElementTypes(\Magento\Framework\Data\Form\AbstractForm $baseElement)
protected function _addElementTypes(AbstractForm $baseElement)
{
$types = $this->_getAdditionalElementTypes();
foreach ($types as $code => $className) {
Expand All @@ -273,7 +277,7 @@ protected function _getAdditionalElementTypes()
/**
* Render additional element
*
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @param AbstractElement $element
* @return string
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
Expand Down
Loading

0 comments on commit 301d73d

Please sign in to comment.