Skip to content

Commit 077db11

Browse files
author
Andrii Kasian
committed
Merge remote-tracking branch 'mainline/develop' into MAGETWO-32622
2 parents 275e786 + 61b5c11 commit 077db11

File tree

842 files changed

+21676
-9827
lines changed

Some content is hidden

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

842 files changed

+21676
-9827
lines changed

app/code/Magento/Backend/App/Config.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
namespace Magento\Backend\App;
1212

13+
use Magento\Framework\App\Config\ScopeConfigInterface;
14+
1315
/**
1416
* Backend config accessor
1517
*/
@@ -36,7 +38,7 @@ public function __construct(\Magento\Framework\App\Config\ScopePool $scopePool)
3638
*/
3739
public function getValue($path)
3840
{
39-
return $this->_scopePool->getScope(\Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT, null)->getValue($path);
41+
return $this->_scopePool->getScope(ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null)->getValue($path);
4042
}
4143

4244
/**
@@ -48,7 +50,7 @@ public function getValue($path)
4850
*/
4951
public function setValue($path, $value)
5052
{
51-
$this->_scopePool->getScope(\Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT, null)->setValue($path, $value);
53+
$this->_scopePool->getScope(ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null)->setValue($path, $value);
5254
}
5355

5456
/**
@@ -59,6 +61,6 @@ public function setValue($path, $value)
5961
*/
6062
public function isSetFlag($path)
6163
{
62-
return !!$this->_scopePool->getScope(\Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT, null)->getValue($path);
64+
return !!$this->_scopePool->getScope(ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null)->getValue($path);
6365
}
6466
}

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

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ protected function _addSubMenu($menuItem, $level, $limit, $id = null)
436436
* @param array $colBrakes
437437
* @return string HTML
438438
* @SuppressWarnings(PHPMD.NPathComplexity)
439+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
439440
*/
440441
public function renderNavigation($menu, $level = 0, $limit = 0, $colBrakes = [])
441442
{
@@ -454,21 +455,30 @@ public function renderNavigation($menu, $level = 0, $limit = 0, $colBrakes = [])
454455
}
455456

456457
$id = $this->getJsId($menuItem->getId());
457-
$output .= '<li ' . $this->getUiId(
458-
$menuItem->getId()
459-
) . ' class="item-' . $itemClass . ' ' . $this->_renderItemCssClass(
460-
$menuItem,
461-
$level
462-
) . ($level == 0 ? '" id="' . $id . '" aria-haspopup="true' : '')
463-
. '" role="menu-item">' . $this->_renderAnchor(
464-
$menuItem,
465-
$level
466-
) . $this->_addSubMenu(
467-
$menuItem,
468-
$level,
469-
$limit,
470-
$id
471-
) . '</li>';
458+
if (count($menu) > 1 || $level != 1) {
459+
$output .= '<li ' . $this->getUiId(
460+
$menuItem->getId()
461+
) . ' class="item-' . $itemClass . ' ' . $this->_renderItemCssClass(
462+
$menuItem,
463+
$level
464+
) . ($level == 0 ? '" id="' . $id . '" aria-haspopup="true' : '')
465+
. '" role="menu-item">' . $this->_renderAnchor(
466+
$menuItem,
467+
$level
468+
) . $this->_addSubMenu(
469+
$menuItem,
470+
$level,
471+
$limit,
472+
$id
473+
) . '</li>';
474+
} else {
475+
$output .= $this->_addSubMenu(
476+
$menuItem,
477+
$level,
478+
$limit,
479+
$id);
480+
}
481+
472482
$itemPosition++;
473483
}
474484

app/code/Magento/Backend/Block/Page/System/Config/Robots/Reset.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
namespace Magento\Backend\Block\Page\System\Config\Robots;
1010

11+
use Magento\Framework\App\Config\ScopeConfigInterface;
12+
1113
/**
1214
* "Reset to Defaults" button renderer
1315
*
@@ -50,7 +52,7 @@ protected function _construct()
5052
public function getRobotsDefaultCustomInstructions()
5153
{
5254
return trim((string)$this->_scopeConfig->getValue(
53-
self::XML_PATH_ROBOTS_DEFAULT_CUSTOM_INSTRUCTIONS, \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT
55+
self::XML_PATH_ROBOTS_DEFAULT_CUSTOM_INSTRUCTIONS, ScopeConfigInterface::SCOPE_TYPE_DEFAULT
5456
));
5557
}
5658

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Backend\Console\Command;
8+
9+
use Magento\Framework\App\Cache\Manager;
10+
use Symfony\Component\Console\Command\Command;
11+
use Symfony\Component\Console\Input\InputOption;
12+
13+
abstract class AbstractCacheCommand extends Command
14+
{
15+
/**
16+
* Input option bootsrap
17+
*/
18+
const INPUT_KEY_BOOTSTRAP = 'bootstrap';
19+
20+
/**
21+
* CacheManager
22+
*
23+
* @var Manager
24+
*/
25+
protected $cacheManager;
26+
27+
/**
28+
* Constructor
29+
*
30+
* @param Manager $cacheManager
31+
*/
32+
public function __construct(Manager $cacheManager)
33+
{
34+
$this->cacheManager = $cacheManager;
35+
parent::__construct();
36+
}
37+
38+
/**
39+
* {@inheritdoc}
40+
*/
41+
protected function configure()
42+
{
43+
$this->addOption(
44+
self::INPUT_KEY_BOOTSTRAP,
45+
null,
46+
InputOption::VALUE_REQUIRED,
47+
'add or override parameters of the bootstrap'
48+
);
49+
}
50+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Backend\Console\Command;
8+
9+
use Symfony\Component\Console\Input\InputArgument;
10+
use Symfony\Component\Console\Input\InputInterface;
11+
use Symfony\Component\Console\Input\InputOption;
12+
13+
abstract class AbstractCacheManageCommand extends AbstractCacheCommand
14+
{
15+
/**
16+
* Input argument types
17+
*/
18+
const INPUT_KEY_TYPES = 'types';
19+
20+
/**
21+
* Input key all
22+
*/
23+
const INPUT_KEY_ALL = 'all';
24+
25+
/**
26+
* {@inheritdoc}
27+
*/
28+
protected function configure()
29+
{
30+
$this->addArgument(
31+
self::INPUT_KEY_TYPES,
32+
InputArgument::IS_ARRAY,
33+
'List of cache types, space separated. If omitted, all caches will be affected'
34+
);
35+
$this->addOption(
36+
self::INPUT_KEY_ALL,
37+
null,
38+
InputOption::VALUE_NONE,
39+
'All cache types'
40+
);
41+
parent::configure();
42+
}
43+
44+
45+
/**
46+
* Get requested cache types
47+
*
48+
* @param InputInterface $input
49+
* @return array
50+
*/
51+
protected function getRequestedTypes(InputInterface $input)
52+
{
53+
$requestedTypes = [];
54+
if ($input->getArgument(self::INPUT_KEY_TYPES)) {
55+
$requestedTypes = $input->getArgument(self::INPUT_KEY_TYPES);
56+
$requestedTypes = array_filter(array_map('trim', $requestedTypes), 'strlen');
57+
}
58+
if (empty($requestedTypes)) {
59+
return [];
60+
} else {
61+
$availableTypes = $this->cacheManager->getAvailableTypes();
62+
$unsupportedTypes = array_diff($requestedTypes, $availableTypes);
63+
if ($unsupportedTypes) {
64+
throw new \InvalidArgumentException(
65+
"The following requested cache types are not supported: '" . join("', '", $unsupportedTypes)
66+
. "'." . PHP_EOL . 'Supported types: ' . join(", ", $availableTypes)
67+
);
68+
}
69+
return array_values(array_intersect($availableTypes, $requestedTypes));
70+
}
71+
}
72+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Backend\Console\Command;
8+
9+
use Symfony\Component\Console\Input\InputInterface;
10+
use Symfony\Component\Console\Output\OutputInterface;
11+
12+
abstract class AbstractCacheSetCommand extends AbstractCacheManageCommand
13+
{
14+
/**
15+
* Is enable cache or not
16+
*
17+
* @return bool
18+
*/
19+
abstract protected function isEnable();
20+
21+
/**
22+
* {@inheritdoc}
23+
*/
24+
protected function execute(InputInterface $input, OutputInterface $output)
25+
{
26+
$isEnable = $this->isEnable();
27+
if ($input->getOption(self::INPUT_KEY_ALL)) {
28+
$types = $this->cacheManager->getAvailableTypes();
29+
} else {
30+
$types = $this->getRequestedTypes($input);
31+
}
32+
$changedTypes = $this->cacheManager->setEnabled($types, $isEnable);
33+
if ($changedTypes) {
34+
$output->writeln('Changed cache status:');
35+
foreach ($changedTypes as $type) {
36+
$output->writeln(sprintf('%30s: %d -> %d', $type, !$isEnable, $isEnable));
37+
}
38+
} else {
39+
$output->writeln('There is nothing to change in cache status');
40+
}
41+
if (!empty($changedTypes) && $isEnable) {
42+
$this->cacheManager->clean($changedTypes);
43+
$output->writeln('Cleaned cache types:');
44+
$output->writeln(join(PHP_EOL, $changedTypes));
45+
}
46+
}
47+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Backend\Console\Command;
8+
9+
use Symfony\Component\Console\Input\InputInterface;
10+
use Symfony\Component\Console\Output\OutputInterface;
11+
12+
abstract class AbstractCacheTypeManageCommand extends AbstractCacheManageCommand
13+
{
14+
/**
15+
* Perform a cache management action on cache types
16+
*
17+
* @param array $cacheTypes
18+
* @return void
19+
*/
20+
abstract protected function performAction(array $cacheTypes);
21+
22+
/**
23+
* Get display message
24+
*
25+
* @return string
26+
*/
27+
abstract protected function getDisplayMessage();
28+
29+
/**
30+
* Perform cache management action
31+
*
32+
* @param InputInterface $input
33+
* @param OutputInterface $output
34+
* @return void
35+
*/
36+
protected function execute(InputInterface $input, OutputInterface $output)
37+
{
38+
if ($input->getOption(self::INPUT_KEY_ALL)) {
39+
$types = $this->cacheManager->getAvailableTypes();
40+
} else {
41+
$types = $this->getRequestedTypes($input);
42+
}
43+
$this->performAction($types);
44+
$output->writeln($this->getDisplayMessage());
45+
$output->writeln(join(PHP_EOL, $types));
46+
}
47+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Backend\Console\Command;
8+
9+
/**
10+
* Command for cleaning cache
11+
*/
12+
class CacheCleanCommand extends AbstractCacheTypeManageCommand
13+
{
14+
/**
15+
* {@inheritdoc}
16+
*/
17+
protected function configure()
18+
{
19+
$this->setName('cache:clean');
20+
$this->setDescription('Cleans cache type(s)');
21+
parent::configure();
22+
}
23+
24+
/**
25+
* Cleans cache types
26+
*
27+
* @param array $cacheTypes
28+
* @return void
29+
*/
30+
protected function performAction(array $cacheTypes)
31+
{
32+
$this->cacheManager->clean($cacheTypes);
33+
}
34+
35+
/**
36+
* {@inheritdoc}
37+
*/
38+
protected function getDisplayMessage()
39+
{
40+
return 'Cleaned cache types:';
41+
}
42+
}

0 commit comments

Comments
 (0)