Skip to content

Commit 9ece610

Browse files
committed
Merge branch '2.2-develop' into ENGCOM-660-magento-engcom-magento2ce-1140
2 parents 4f6296c + 9c538a1 commit 9ece610

File tree

1,333 files changed

+48711
-24287
lines changed

Some content is hidden

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

1,333 files changed

+48711
-24287
lines changed

COPYING.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright © 2013-2017 Magento, Inc.
1+
Copyright © 2013-present Magento, Inc.
22

33
Each Magento source file included in this distribution is licensed under OSL 3.0 or the Magento Enterprise Edition (MEE) license
44

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
Welcome to Magento 2 installation! We're glad you chose to install Magento 2, a cutting edge, feature-rich eCommerce solution that gets results.
66

77
## Magento system requirements
8-
[Magento system requirements](http://devdocs.magento.com/magento-system-requirements.html)
8+
[Magento system requirements](http://devdocs.magento.com/guides/v2.2/install-gde/system-requirements2.html)
99

1010
## Install Magento
1111
To install Magento, see either:
1212

1313
* [Magento DevBox](https://magento.com/tech-resources/download), the easiest way to get started with Magento.
14-
* [Installation guide](http://devdocs.magento.com/guides/v2.0/install-gde/bk-install-guide.html)
14+
* [Installation guide](http://devdocs.magento.com/guides/v2.2/install-gde/bk-install-guide.html)
1515

1616
<h2>Contributing to the Magento 2 code base</h2>
1717
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.
@@ -22,8 +22,8 @@ To learn about issues, click [here][2]. To open an issue, click [here][3].
2222

2323
To suggest documentation improvements, click [here][4].
2424

25-
[1]: <http://devdocs.magento.com/guides/v2.0/contributor-guide/contributing.html>
26-
[2]: <http://devdocs.magento.com/guides/v2.0/contributor-guide/contributing.html#report>
25+
[1]: <http://devdocs.magento.com/guides/v2.2/contributor-guide/contributing.html>
26+
[2]: <http://devdocs.magento.com/guides/v2.2/contributor-guide/contributing.html#report>
2727
[3]: <https://github.com/magento/magento2/issues>
2828
[4]: <http://devdocs.magento.com>
2929

app/bootstrap.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
if (!defined('PHP_VERSION_ID') || !(PHP_VERSION_ID === 70002 || PHP_VERSION_ID === 70004 || PHP_VERSION_ID >= 70006)) {
1515
if (PHP_SAPI == 'cli') {
1616
echo 'Magento supports 7.0.2, 7.0.4, and 7.0.6 or later. ' .
17-
'Please read http://devdocs.magento.com/guides/v1.0/install-gde/system-requirements.html';
17+
'Please read http://devdocs.magento.com/guides/v2.2/install-gde/system-requirements.html';
1818
} else {
1919
echo <<<HTML
2020
<div style="font:12px/1.35em arial, helvetica, sans-serif;">
2121
<p>Magento supports PHP 7.0.2, 7.0.4, and 7.0.6 or later. Please read
22-
<a target="_blank" href="http://devdocs.magento.com/guides/v1.0/install-gde/system-requirements.html">
22+
<a target="_blank" href="http://devdocs.magento.com/guides/v2.2/install-gde/system-requirements.html">
2323
Magento System Requirements</a>.
2424
</div>
2525
HTML;

app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassRemove.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ public function execute()
3939
$this->messageManager->addException($e, __("We couldn't remove the messages because of an error."));
4040
}
4141
}
42-
$this->getResponse()->setRedirect($this->_redirect->getRedirectUrl($this->getUrl('*')));
42+
$this->_redirect('adminhtml/*/');
4343
}
4444
}

app/code/Magento/Analytics/Block/Adminhtml/System/Config/CollectionTimeLabel.php

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,45 @@
55
*/
66
namespace Magento\Analytics\Block\Adminhtml\System\Config;
77

8+
use Magento\Framework\App\ObjectManager;
9+
810
/**
911
* Provides label with default Time Zone
1012
*/
1113
class CollectionTimeLabel extends \Magento\Config\Block\System\Config\Form\Field
1214
{
1315
/**
14-
* Add default time zone to comment
16+
* @var \Magento\Framework\Locale\ResolverInterface
17+
*/
18+
private $localeResolver;
19+
20+
/**
21+
* @param \Magento\Backend\Block\Template\Context $context
22+
* @param array $data
23+
* @param \Magento\Framework\Locale\ResolverInterface|null $localeResolver
24+
*/
25+
public function __construct(
26+
\Magento\Backend\Block\Template\Context $context,
27+
array $data = [],
28+
\Magento\Framework\Locale\ResolverInterface $localeResolver = null
29+
) {
30+
$this->localeResolver = $localeResolver ?:
31+
ObjectManager::getInstance()->get(\Magento\Framework\Locale\ResolverInterface::class);
32+
parent::__construct($context, $data);
33+
}
34+
35+
/**
36+
* Add current time zone to comment, properly translated according to locale
1537
*
1638
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
1739
* @return string
1840
*/
1941
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
2042
{
2143
$timeZoneCode = $this->_localeDate->getConfigTimezone();
22-
$getLongTimeZoneName = \IntlTimeZone::createTimeZone($timeZoneCode)->getDisplayName();
44+
$locale = $this->localeResolver->getLocale();
45+
$getLongTimeZoneName = \IntlTimeZone::createTimeZone($timeZoneCode)
46+
->getDisplayName(false, \IntlTimeZone::DISPLAY_LONG, $locale);
2347
$element->setData(
2448
'comment',
2549
sprintf("%s (%s)", $getLongTimeZoneName, $timeZoneCode)

app/code/Magento/Backend/Block/Cache.php

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,29 @@ protected function _construct()
2222
$this->_headerText = __('Cache Storage Management');
2323
parent::_construct();
2424
$this->buttonList->remove('add');
25-
$this->buttonList->add(
26-
'flush_magento',
27-
[
28-
'label' => __('Flush Magento Cache'),
29-
'onclick' => 'setLocation(\'' . $this->getFlushSystemUrl() . '\')',
30-
'class' => 'primary flush-cache-magento'
31-
]
32-
);
3325

34-
$message = __('The cache storage may contain additional data. Are you sure that you want to flush it?');
35-
$this->buttonList->add(
36-
'flush_system',
37-
[
38-
'label' => __('Flush Cache Storage'),
39-
'onclick' => 'confirmSetLocation(\'' . $message . '\', \'' . $this->getFlushStorageUrl() . '\')',
40-
'class' => 'flush-cache-storage'
41-
]
42-
);
26+
if ($this->_authorization->isAllowed('Magento_Backend::flush_magento_cache')) {
27+
$this->buttonList->add(
28+
'flush_magento',
29+
[
30+
'label' => __('Flush Magento Cache'),
31+
'onclick' => 'setLocation(\'' . $this->getFlushSystemUrl() . '\')',
32+
'class' => 'primary flush-cache-magento'
33+
]
34+
);
35+
}
36+
37+
if ($this->_authorization->isAllowed('Magento_Backend::flush_cache_storage')) {
38+
$message = __('The cache storage may contain additional data. Are you sure that you want to flush it?');
39+
$this->buttonList->add(
40+
'flush_system',
41+
[
42+
'label' => __('Flush Cache Storage'),
43+
'onclick' => 'confirmSetLocation(\'' . $message . '\', \'' . $this->getFlushStorageUrl() . '\')',
44+
'class' => 'flush-cache-storage'
45+
]
46+
);
47+
}
4348
}
4449

4550
/**
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Backend\Block\Cache;
8+
9+
use Magento\Framework\AuthorizationInterface;
10+
use Magento\Framework\View\Element\Block\ArgumentInterface;
11+
12+
/**
13+
* Class Permissions
14+
*/
15+
class Permissions implements ArgumentInterface
16+
{
17+
/**
18+
* @var AuthorizationInterface
19+
*/
20+
private $authorization;
21+
22+
/**
23+
* Permissions constructor.
24+
*
25+
* @param AuthorizationInterface $authorization
26+
*/
27+
public function __construct(AuthorizationInterface $authorization)
28+
{
29+
$this->authorization = $authorization;
30+
}
31+
32+
/**
33+
* @return bool
34+
*/
35+
public function hasAccessToFlushCatalogImages()
36+
{
37+
return $this->authorization->isAllowed('Magento_Backend::flush_catalog_images');
38+
}
39+
/**
40+
* @return bool
41+
*/
42+
public function hasAccessToFlushJsCss()
43+
{
44+
return $this->authorization->isAllowed('Magento_Backend::flush_js_css');
45+
}
46+
/**
47+
* @return bool
48+
*/
49+
public function hasAccessToFlushStaticFiles()
50+
{
51+
return $this->authorization->isAllowed('Magento_Backend::flush_static_files');
52+
}
53+
/**
54+
* @return bool
55+
*/
56+
public function hasAccessToAdditionalActions()
57+
{
58+
return ($this->hasAccessToFlushCatalogImages()
59+
|| $this->hasAccessToFlushJsCss()
60+
|| $this->hasAccessToFlushStaticFiles());
61+
}
62+
}

app/code/Magento/Backend/Block/GlobalSearch.php

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

9+
use Magento\Backend\Model\GlobalSearch\SearchEntityFactory;
10+
use Magento\Backend\Model\GlobalSearch\SearchEntity;
11+
use Magento\Framework\App\ObjectManager;
12+
813
/**
914
* @api
1015
* @since 100.0.2
1116
*/
1217
class GlobalSearch extends \Magento\Backend\Block\Template
1318
{
19+
/**
20+
* @var SearchEntityFactory
21+
*/
22+
private $searchEntityFactory;
23+
1424
/**
1525
* @var string
1626
*/
1727
protected $_template = 'Magento_Backend::system/search.phtml';
1828

29+
/**
30+
* @var array
31+
*/
32+
private $entityResources;
33+
34+
/**
35+
* @var array
36+
*/
37+
private $entityPaths;
38+
39+
/**
40+
* @param Template\Context $context
41+
* @param array $data
42+
* @param array $entityResources
43+
* @param array $entityPaths
44+
* @param SearchEntityFactory|null $searchEntityFactory
45+
*/
46+
public function __construct(
47+
Template\Context $context,
48+
array $data = [],
49+
array $entityResources = [],
50+
array $entityPaths = [],
51+
SearchEntityFactory $searchEntityFactory = null
52+
) {
53+
$this->entityResources = $entityResources;
54+
$this->entityPaths = $entityPaths;
55+
$this->searchEntityFactory = $searchEntityFactory ?: ObjectManager::getInstance()
56+
->get(SearchEntityFactory::class);
57+
58+
parent::__construct($context, $data);
59+
}
60+
1961
/**
2062
* Get components configuration
2163
* @return array
@@ -34,4 +76,48 @@ public function getWidgetInitOptions()
3476
]
3577
];
3678
}
79+
80+
/**
81+
* Get entities which are allowed to show.
82+
*
83+
* @return SearchEntity[]
84+
*/
85+
public function getEntitiesToShow()
86+
{
87+
$allowedEntityTypes = [];
88+
$entitiesToShow = [];
89+
90+
foreach ($this->entityResources as $entityType => $resource) {
91+
if ($this->getAuthorization()->isAllowed($resource)) {
92+
$allowedEntityTypes[] = $entityType;
93+
}
94+
}
95+
96+
foreach ($allowedEntityTypes as $entityType) {
97+
$url = $this->getUrlEntityType($entityType);
98+
99+
$searchEntity = $this->searchEntityFactory->create();
100+
$searchEntity->setId('searchPreview' . $entityType);
101+
$searchEntity->setTitle('in ' . $entityType);
102+
$searchEntity->setUrl($url);
103+
104+
$entitiesToShow[] = $searchEntity;
105+
}
106+
107+
return $entitiesToShow;
108+
}
109+
110+
/**
111+
* Get url path by entity type.
112+
*
113+
* @param string $entityType
114+
*
115+
* @return string
116+
*/
117+
private function getUrlEntityType(string $entityType)
118+
{
119+
$urlPath = $this->entityPaths[$entityType] ?? '';
120+
121+
return $this->getUrl($urlPath);
122+
}
37123
}

app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Date.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public function getHtml()
127127

128128
/**
129129
* @param string|null $index
130-
* @return string
130+
* @return array|string|int|float|null
131131
*/
132132
public function getEscapedValue($index = null)
133133
{
@@ -138,6 +138,11 @@ public function getEscapedValue($index = null)
138138
$this->_localeDate->getDateFormat(\IntlDateFormatter::SHORT)
139139
);
140140
}
141+
142+
if (is_string($value)) {
143+
return $this->escapeHtml($value);
144+
}
145+
141146
return $value;
142147
}
143148

app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Datetime.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ public function getHtml()
140140
/**
141141
* Return escaped value for calendar
142142
*
143-
* @param string $index
144-
* @return string
143+
* @param string|null $index
144+
* @return array|string|int|float|null
145145
*/
146146
public function getEscapedValue($index = null)
147147
{
@@ -150,6 +150,11 @@ public function getEscapedValue($index = null)
150150
if ($value instanceof \DateTimeInterface) {
151151
return $this->_localeDate->formatDateTime($value);
152152
}
153+
154+
if (is_string($value)) {
155+
return $this->escapeHtml($value);
156+
}
157+
153158
return $value;
154159
}
155160

0 commit comments

Comments
 (0)