Skip to content

Commit 3941c63

Browse files
committed
Merge pull request #96 from magento-south/MAGETWO-30789
[South] Sprint 30
2 parents f2361bd + cd69470 commit 3941c63

File tree

263 files changed

+5121
-1258
lines changed

Some content is hidden

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

263 files changed

+5121
-1258
lines changed

app/code/Magento/Backend/Model/View.php

Lines changed: 0 additions & 63 deletions
This file was deleted.

app/code/Magento/Backend/Model/View/Layout/Builder.php

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,6 @@
1111

1212
class Builder extends \Magento\Framework\View\Layout\Builder
1313
{
14-
/**
15-
* @var Filter\Acl
16-
*/
17-
protected $aclFilter;
18-
19-
/**
20-
* @param View\LayoutInterface $layout
21-
* @param App\Request\Http $request
22-
* @param Event\ManagerInterface $eventManager
23-
* @param Filter\Acl $aclFilter
24-
*/
25-
public function __construct(
26-
View\LayoutInterface $layout,
27-
App\Request\Http $request,
28-
Event\ManagerInterface $eventManager,
29-
Filter\Acl $aclFilter
30-
) {
31-
parent::__construct($layout, $request, $eventManager);
32-
$this->aclFilter = $aclFilter;
33-
}
34-
35-
/**
36-
* @return $this
37-
*/
38-
protected function beforeGenerateBlock()
39-
{
40-
$this->aclFilter->filterAclNodes($this->layout->getNode());
41-
return $this;
42-
}
43-
4414
/**
4515
* @return $this
4616
*/

app/code/Magento/Backend/Model/View/Layout/Filter/Acl.php

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,39 +7,68 @@
77
*/
88
namespace Magento\Backend\Model\View\Layout\Filter;
99

10+
use Magento\Framework\View\Layout\ScheduledStructure;
11+
use Magento\Framework\View\Layout\Data\Structure;
12+
1013
class Acl
1114
{
1215
/**
1316
* Authorization
1417
*
1518
* @var \Magento\Framework\AuthorizationInterface
1619
*/
17-
protected $_authorization;
20+
protected $authorization;
1821

1922
/**
2023
* @param \Magento\Framework\AuthorizationInterface $authorization
2124
*/
2225
public function __construct(\Magento\Framework\AuthorizationInterface $authorization)
2326
{
24-
$this->_authorization = $authorization;
27+
$this->authorization = $authorization;
2528
}
2629

2730
/**
28-
* Delete nodes that have "acl" attribute but value is "not allowed"
31+
* Delete elements that have "acl" attribute but value is "not allowed"
2932
* In any case, the "acl" attribute will be unset
3033
*
31-
* @param \Magento\Framework\Simplexml\Element $xml
32-
* @return void
34+
* @param ScheduledStructure $scheduledStructure
35+
* @param Structure $structure
3336
*/
34-
public function filterAclNodes(\Magento\Framework\Simplexml\Element $xml)
37+
public function filterAclElements(ScheduledStructure $scheduledStructure, Structure $structure)
3538
{
36-
$limitations = $xml->xpath('//*[@acl]') ?: [];
37-
foreach ($limitations as $node) {
38-
if (!$this->_authorization->isAllowed($node['acl'])) {
39-
$node->unsetSelf();
40-
} else {
41-
unset($node['acl']);
39+
foreach ($scheduledStructure->getElements() as $name => $data) {
40+
list(, $data) = $data;
41+
if (isset($data['attributes']['acl']) && $data['attributes']['acl']) {
42+
if (!$this->authorization->isAllowed($data['attributes']['acl'])) {
43+
$this->removeElement($scheduledStructure, $structure, $name);
44+
}
4245
}
4346
}
4447
}
48+
49+
/**
50+
* Remove scheduled element
51+
*
52+
* @param ScheduledStructure $scheduledStructure
53+
* @param Structure $structure
54+
* @param string $elementName
55+
* @param bool $isChild
56+
* @return $this
57+
*/
58+
protected function removeElement(
59+
ScheduledStructure $scheduledStructure,
60+
Structure $structure,
61+
$elementName,
62+
$isChild = false
63+
) {
64+
$elementsToRemove = array_keys($structure->getChildren($elementName));
65+
$scheduledStructure->unsetElement($elementName);
66+
foreach ($elementsToRemove as $element) {
67+
$this->removeElement($scheduledStructure, $structure, $element, true);
68+
}
69+
if (!$isChild) {
70+
$structure->unsetElement($elementName);
71+
}
72+
return $this;
73+
}
4574
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Backend\Model\View\Layout;
7+
8+
use Magento\Framework\View\Layout\ScheduledStructure;
9+
use Magento\Framework\View\Layout\Data\Structure;
10+
11+
/**
12+
* Pool of generators for structural elements
13+
*/
14+
class GeneratorPool extends \Magento\Framework\View\Layout\GeneratorPool
15+
{
16+
/**
17+
* @var Filter\Acl
18+
*/
19+
protected $aclFilter;
20+
21+
/**
22+
* @param ScheduledStructure\Helper $helper
23+
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
24+
* @param \Magento\Framework\App\ScopeResolverInterface $scopeResolver
25+
* @param Filter\Acl $aclFilter
26+
* @param array $generators
27+
*/
28+
public function __construct(
29+
ScheduledStructure\Helper $helper,
30+
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
31+
\Magento\Framework\App\ScopeResolverInterface $scopeResolver,
32+
Filter\Acl $aclFilter,
33+
array $generators = null
34+
) {
35+
$this->aclFilter = $aclFilter;
36+
parent::__construct(
37+
$helper,
38+
$scopeConfig,
39+
$scopeResolver,
40+
$generators
41+
);
42+
}
43+
44+
/**
45+
* Build structure that is based on scheduled structure
46+
*
47+
* @param ScheduledStructure $scheduledStructure
48+
* @param Structure $structure
49+
* @return $this
50+
*/
51+
protected function buildStructure(ScheduledStructure $scheduledStructure, Structure $structure)
52+
{
53+
parent::buildStructure($scheduledStructure, $structure);
54+
$this->aclFilter->filterAclElements($scheduledStructure, $structure);
55+
return $this;
56+
}
57+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Backend\Model\View\Layout\Reader;
7+
8+
use Magento\Framework\View\Layout;
9+
use Magento\Framework\Data\Argument\InterpreterInterface;
10+
11+
/**
12+
* Backend block structure reader with ACL support
13+
*/
14+
class Block extends Layout\Reader\Block
15+
{
16+
public function __construct(
17+
Layout\ScheduledStructure\Helper $helper,
18+
Layout\Argument\Parser $argumentParser,
19+
Layout\ReaderPool $readerPool,
20+
InterpreterInterface $argumentInterpreter,
21+
$scopeType = null
22+
) {
23+
$this->attributes[] = 'acl';
24+
parent::__construct(
25+
$helper,
26+
$argumentParser,
27+
$readerPool,
28+
$argumentInterpreter,
29+
$scopeType
30+
);
31+
}
32+
}

app/code/Magento/Backend/Model/View/Page/Builder.php

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,40 +12,6 @@
1212

1313
class Builder extends View\Page\Builder
1414
{
15-
/**
16-
* @var Layout\Filter\Acl $aclFilter
17-
*/
18-
protected $aclFilter;
19-
20-
/**
21-
* @param View\LayoutInterface $layout
22-
* @param App\Request\Http $request
23-
* @param Event\ManagerInterface $eventManager
24-
* @param View\Page\Config $pageConfig
25-
* @param View\Page\Layout\Reader $pageLayoutReader
26-
* @param Layout\Filter\Acl $aclFilter
27-
*/
28-
public function __construct(
29-
View\LayoutInterface $layout,
30-
App\Request\Http $request,
31-
Event\ManagerInterface $eventManager,
32-
View\Page\Config $pageConfig,
33-
View\Page\Layout\Reader $pageLayoutReader,
34-
Layout\Filter\Acl $aclFilter
35-
) {
36-
parent::__construct($layout, $request, $eventManager, $pageConfig, $pageLayoutReader);
37-
$this->aclFilter = $aclFilter;
38-
}
39-
40-
/**
41-
* @return $this
42-
*/
43-
protected function beforeGenerateBlock()
44-
{
45-
$this->aclFilter->filterAclNodes($this->layout->getNode());
46-
return $this;
47-
}
48-
4915
/**
5016
* @return $this
5117
*/

app/code/Magento/Backend/etc/adminhtml/di.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
<preference for="Magento\Framework\App\DefaultPathInterface" type="Magento\Backend\App\DefaultPath" />
1717
<preference for="Magento\Backend\App\ConfigInterface" type="Magento\Backend\App\Config" />
1818
<preference for="Magento\Framework\App\Response\Http\FileFactory" type="Magento\Backend\App\Response\Http\FileFactory" />
19-
<preference for="Magento\Framework\App\View" type="Magento\Backend\Model\View" />
19+
<preference for="Magento\Framework\View\Layout\GeneratorPool" type="Magento\Backend\Model\View\Layout\GeneratorPool" />
20+
<preference for="pageLayoutGeneratorPool" type="Magento\Backend\Model\View\Layout\GeneratorPool" />
21+
<preference for="Magento\Framework\View\Layout\Reader\Block" type="Magento\Backend\Model\View\Layout\Reader\Block" />
2022
<preference for="Magento\Framework\Model\ActionValidator\RemoveAction" type="Magento\Framework\Model\ActionValidator\RemoveAction\Allowed" />
2123
<preference for="Magento\Framework\Session\Config\ConfigInterface" type="Magento\Backend\Model\Session\AdminConfig" />
2224
<type name="Magento\Backend\App\Action\Context">

app/code/Magento/Theme/Model/CopyService.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,10 @@ protected function _copyFilesRecursively($baseDir, $sourceDir, $targetDir)
197197
*/
198198
protected function _deleteFilesRecursively($targetDir)
199199
{
200-
if (!$this->_directory->isExist($targetDir)) {
201-
return;
202-
}
203-
foreach ($this->_directory->read($targetDir) as $path) {
204-
$this->_directory->delete($path);
200+
if ($this->_directory->isExist($targetDir)) {
201+
foreach ($this->_directory->read($targetDir) as $path) {
202+
$this->_directory->delete($path);
203+
}
205204
}
206205
}
207206
}

0 commit comments

Comments
 (0)