Skip to content

Commit 16be019

Browse files
author
He, Joan(johe)
committed
Merge pull request #486 from magento-extensibility/develop
[Extensibility]Sprint 55 pull request
2 parents 6fdf665 + d916f36 commit 16be019

File tree

60 files changed

+758
-839
lines changed

Some content is hidden

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

60 files changed

+758
-839
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@
77

88
class Additional extends \Magento\Backend\Block\Template
99
{
10+
/**
11+
* Check if application is in production mode
12+
*
13+
* @return bool
14+
*/
15+
public function isInProductionMode()
16+
{
17+
return $this->_appState->getMode() === \Magento\Framework\App\State::MODE_PRODUCTION;
18+
}
19+
1020
/**
1121
* @return string
1222
*/
@@ -22,4 +32,12 @@ public function getCleanMediaUrl()
2232
{
2333
return $this->getUrl('*/*/cleanMedia');
2434
}
35+
36+
/**
37+
* @return string
38+
*/
39+
public function getCleanStaticFilesUrl()
40+
{
41+
return $this->getUrl('*/*/cleanStaticFiles');
42+
}
2543
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
/**
3+
*
4+
* Copyright © 2015 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
namespace Magento\Backend\Controller\Adminhtml\Cache;
8+
9+
use Magento\Framework\Controller\ResultFactory;
10+
11+
class CleanStaticFiles extends \Magento\Backend\Controller\Adminhtml\Cache
12+
{
13+
/**
14+
* Clean static files cache
15+
*
16+
* @return \Magento\Backend\Model\View\Result\Redirect
17+
*/
18+
public function execute()
19+
{
20+
$this->_objectManager->get('Magento\Framework\App\State\CleanupFiles')->clearMaterializedViewFiles();
21+
$this->_eventManager->dispatch('clean_static_files_cache_after');
22+
$this->messageManager->addSuccess(__('The static files cache has been cleaned.'));
23+
24+
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
25+
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
26+
return $resultRedirect->setPath('adminhtml/*');
27+
}
28+
}

app/code/Magento/Backend/Setup/ConfigOptionsList.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Framework\Setup\ConfigOptionsListInterface;
1111
use Magento\Framework\Setup\Option\TextConfigOption;
1212
use Magento\Framework\App\DeploymentConfig;
13+
use \Magento\Framework\Setup\BackendFrontnameGenerator;
1314

1415
/*
1516
* Deployment configuration options needed for Backend module
@@ -36,8 +37,7 @@ public function getOptions()
3637
self::INPUT_KEY_BACKEND_FRONTNAME,
3738
TextConfigOption::FRONTEND_WIZARD_TEXT,
3839
self::CONFIG_PATH_BACKEND_FRONTNAME,
39-
'Backend frontname',
40-
'admin'
40+
'Backend frontname (will be autogenerated if missing)'
4141
)
4242
];
4343
}
@@ -50,6 +50,10 @@ public function createConfig(array $options, DeploymentConfig $deploymentConfig)
5050
{
5151
$configData = new ConfigData(ConfigFilePool::APP_ENV);
5252

53+
if (!$deploymentConfig->get(self::CONFIG_PATH_BACKEND_FRONTNAME)
54+
&& !isset($options[self::INPUT_KEY_BACKEND_FRONTNAME])) {
55+
$options[self::INPUT_KEY_BACKEND_FRONTNAME] = BackendFrontnameGenerator::generate();
56+
}
5357
if (isset($options[self::INPUT_KEY_BACKEND_FRONTNAME])) {
5458
$configData->set(self::CONFIG_PATH_BACKEND_FRONTNAME, $options[self::INPUT_KEY_BACKEND_FRONTNAME]);
5559
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Backend\Test\Unit\Block\Cache;
8+
9+
class AdditionalTest extends \PHPUnit_Framework_TestCase
10+
{
11+
/**
12+
* @var \Magento\Backend\Block\Cache\Additional
13+
*/
14+
private $additonalBlock;
15+
16+
/**
17+
* @var \Magento\Framework\UrlInterface|\PHPUnit_Framework_MockObject_MockObject
18+
*/
19+
protected $urlBuilderMock;
20+
21+
/**
22+
* @var \Magento\Framework\App\State | \PHPUnit_Framework_MockObject_MockObject
23+
*/
24+
protected $appStateMock;
25+
26+
protected function setUp()
27+
{
28+
$this->urlBuilderMock = $this->getMock('Magento\Framework\UrlInterface');
29+
$this->appStateMock = $this->getMockBuilder('Magento\Framework\App\State')
30+
->disableOriginalConstructor()
31+
->getMock();
32+
33+
$objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
34+
$context = $objectHelper->getObject(
35+
'Magento\Backend\Block\Template\Context',
36+
[
37+
'urlBuilder' => $this->urlBuilderMock,
38+
'appState' => $this->appStateMock,
39+
]
40+
);
41+
42+
$this->additonalBlock = $objectHelper->getObject(
43+
'Magento\Backend\Block\Cache\Additional',
44+
['context' => $context]
45+
);
46+
}
47+
48+
public function testGetCleanImagesUrl()
49+
{
50+
$expectedUrl = 'cleanImagesUrl';
51+
$this->urlBuilderMock->expects($this->once())
52+
->method('getUrl')
53+
->with('*/*/cleanImages')
54+
->will($this->returnValue($expectedUrl));
55+
$this->assertEquals($expectedUrl, $this->additonalBlock->getCleanImagesUrl());
56+
}
57+
58+
public function testGetCleanMediaUrl()
59+
{
60+
$expectedUrl = 'cleanMediaUrl';
61+
$this->urlBuilderMock->expects($this->once())
62+
->method('getUrl')
63+
->with('*/*/cleanMedia')
64+
->will($this->returnValue($expectedUrl));
65+
$this->assertEquals($expectedUrl, $this->additonalBlock->getCleanMediaUrl());
66+
}
67+
68+
public function testGetCleanStaticFiles()
69+
{
70+
$expectedUrl = 'cleanStaticFilesUrl';
71+
$this->urlBuilderMock->expects($this->once())
72+
->method('getUrl')
73+
->with('*/*/cleanStaticFiles')
74+
->will($this->returnValue($expectedUrl));
75+
$this->assertEquals($expectedUrl, $this->additonalBlock->getCleanStaticFilesUrl());
76+
}
77+
78+
/**
79+
* @param string $mode
80+
* @param bool $expected
81+
* @dataProvider isInProductionModeDataProvider
82+
*/
83+
public function testIsInProductionMode($mode, $expected)
84+
{
85+
$this->appStateMock->expects($this->once())
86+
->method('getMode')
87+
->willReturn($mode);
88+
$this->assertEquals($expected, $this->additonalBlock->isInProductionMode());
89+
}
90+
91+
public function isInProductionModeDataProvider()
92+
{
93+
return [
94+
[\Magento\Framework\App\State::MODE_DEFAULT, false],
95+
[\Magento\Framework\App\State::MODE_DEVELOPER, false],
96+
[\Magento\Framework\App\State::MODE_PRODUCTION, true],
97+
];
98+
}
99+
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
// @codingStandardsIgnoreFile
8+
9+
namespace Magento\Backend\Test\Unit\Controller\Adminhtml\Cache;
10+
11+
class CleanStaticFilesTest extends \PHPUnit_Framework_TestCase
12+
{
13+
/**
14+
* @var \Magento\Framework\ObjectManagerInterface | \PHPUnit_Framework_MockObject_MockObject
15+
*/
16+
private $objectManagerMock;
17+
18+
/**
19+
* @var \Magento\Framework\Event\ManagerInterface | \PHPUnit_Framework_MockObject_MockObject
20+
*/
21+
private $eventManagerMock;
22+
23+
/**
24+
* @var \Magento\Framework\Message\ManagerInterface | \PHPUnit_Framework_MockObject_MockObject
25+
*/
26+
private $messageManagerMock;
27+
28+
/**
29+
* @var \Magento\Framework\Controller\ResultFactory | \PHPUnit_Framework_MockObject_MockObject
30+
*/
31+
private $resultFactoryMock;
32+
33+
/**
34+
* @var \Magento\Backend\Controller\Adminhtml\Cache\CleanStaticFiles
35+
*/
36+
private $controller;
37+
38+
protected function setUp()
39+
{
40+
$this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface');
41+
$this->eventManagerMock = $this->getMockBuilder('Magento\Framework\Event\ManagerInterface')
42+
->disableOriginalConstructor()
43+
->getMock();
44+
$this->messageManagerMock = $this->getMockBuilder('Magento\Framework\Message\ManagerInterface')
45+
->disableOriginalConstructor()
46+
->getMock();
47+
$this->resultFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\ResultFactory')
48+
->disableOriginalConstructor()
49+
->getMock();
50+
$objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
51+
$context = $objectHelper->getObject(
52+
'\Magento\Backend\App\Action\Context',
53+
[
54+
'objectManager' => $this->objectManagerMock,
55+
'eventManager' => $this->eventManagerMock,
56+
'messageManager' => $this->messageManagerMock,
57+
'resultFactory' => $this->resultFactoryMock,
58+
]
59+
);
60+
61+
$this->controller = $objectHelper->getObject(
62+
'Magento\Backend\Controller\Adminhtml\Cache\CleanStaticFiles',
63+
['context' => $context,]
64+
);
65+
}
66+
67+
public function testExecute()
68+
{
69+
$cleanupFilesMock = $this->getMockBuilder('Magento\Framework\App\State\CleanupFiles')
70+
->disableOriginalConstructor()
71+
->getMock();
72+
$cleanupFilesMock->expects($this->once())
73+
->method('clearMaterializedViewFiles');
74+
$this->objectManagerMock->expects($this->once())->method('get')->will($this->returnValue($cleanupFilesMock));
75+
76+
$this->eventManagerMock->expects($this->once())
77+
->method('dispatch')
78+
->with('clean_static_files_cache_after');
79+
80+
$this->messageManagerMock->expects($this->once())
81+
->method('addSuccess')
82+
->with('The static files cache has been cleaned.');
83+
84+
$resultRedirect = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect')
85+
->disableOriginalConstructor()
86+
->getMock();
87+
$this->resultFactoryMock->expects($this->atLeastOnce())
88+
->method('create')
89+
->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT)
90+
->willReturn($resultRedirect);
91+
$resultRedirect->expects($this->once())
92+
->method('setPath')
93+
->with('adminhtml/*')
94+
->willReturnSelf();
95+
96+
// Run
97+
$this->controller->execute();
98+
}
99+
}

app/code/Magento/Backend/i18n/de_DE.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,8 @@ Scope:,Scope:
412412
"Pregenerated product images files","Pregenerated product images files"
413413
"Flush JavaScript/CSS Cache","Flush JavaScript/CSS Cache"
414414
"Themes JavaScript and CSS files combined to one file.","Themes JavaScript and CSS files combined to one file."
415+
"Flush Static Files Cache", "Flush Static Files Cache"
416+
"Preprocessed view files and static files", "Preprocessed view files and static files"
415417
Catalog,Catalog
416418
JavaScript/CSS,JavaScript/CSS
417419
"JavaScript/CSS Cache","JavaScript/CSS Cache"

app/code/Magento/Backend/i18n/en_US.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,8 @@ Scope:,Scope:
412412
"Pregenerated product images files","Pregenerated product images files"
413413
"Flush JavaScript/CSS Cache","Flush JavaScript/CSS Cache"
414414
"Themes JavaScript and CSS files combined to one file.","Themes JavaScript and CSS files combined to one file."
415+
"Flush Static Files Cache", "Flush Static Files Cache"
416+
"Preprocessed view files and static files", "Preprocessed view files and static files"
415417
Catalog,Catalog
416418
JavaScript/CSS,JavaScript/CSS
417419
"JavaScript/CSS Cache","JavaScript/CSS Cache"

app/code/Magento/Backend/i18n/es_ES.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,8 @@ Scope:,Scope:
412412
"Pregenerated product images files","Pregenerated product images files"
413413
"Flush JavaScript/CSS Cache","Flush JavaScript/CSS Cache"
414414
"Themes JavaScript and CSS files combined to one file.","Themes JavaScript and CSS files combined to one file."
415+
"Flush Static Files Cache", "Flush Static Files Cache"
416+
"Preprocessed view files and static files", "Preprocessed view files and static files"
415417
Catalog,Catalog
416418
JavaScript/CSS,JavaScript/CSS
417419
"JavaScript/CSS Cache","JavaScript/CSS Cache"

app/code/Magento/Backend/i18n/fr_FR.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,8 @@ Scope:,Scope:
412412
"Pregenerated product images files","Pregenerated product images files"
413413
"Flush JavaScript/CSS Cache","Flush JavaScript/CSS Cache"
414414
"Themes JavaScript and CSS files combined to one file.","Themes JavaScript and CSS files combined to one file."
415+
"Flush Static Files Cache", "Flush Static Files Cache"
416+
"Preprocessed view files and static files", "Preprocessed view files and static files"
415417
Catalog,Catalog
416418
JavaScript/CSS,JavaScript/CSS
417419
"JavaScript/CSS Cache","JavaScript/CSS Cache"

app/code/Magento/Backend/i18n/nl_NL.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,8 @@ Scope:,Scope:
412412
"Pregenerated product images files","Pregenerated product images files"
413413
"Flush JavaScript/CSS Cache","Flush JavaScript/CSS Cache"
414414
"Themes JavaScript and CSS files combined to one file.","Themes JavaScript and CSS files combined to one file."
415+
"Flush Static Files Cache", "Flush Static Files Cache"
416+
"Preprocessed view files and static files", "Preprocessed view files and static files"
415417
Catalog,Catalog
416418
JavaScript/CSS,JavaScript/CSS
417419
"JavaScript/CSS Cache","JavaScript/CSS Cache"

app/code/Magento/Backend/i18n/pt_BR.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,8 @@ Scope:,Scope:
412412
"Pregenerated product images files","Pregenerated product images files"
413413
"Flush JavaScript/CSS Cache","Flush JavaScript/CSS Cache"
414414
"Themes JavaScript and CSS files combined to one file.","Themes JavaScript and CSS files combined to one file."
415+
"Flush Static Files Cache", "Flush Static Files Cache"
416+
"Preprocessed view files and static files", "Preprocessed view files and static files"
415417
Catalog,Catalog
416418
JavaScript/CSS,JavaScript/CSS
417419
"JavaScript/CSS Cache","JavaScript/CSS Cache"

app/code/Magento/Backend/i18n/zh_CN.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,8 @@ Scope:,Scope:
412412
"Pregenerated product images files","Pregenerated product images files"
413413
"Flush JavaScript/CSS Cache","Flush JavaScript/CSS Cache"
414414
"Themes JavaScript and CSS files combined to one file.","Themes JavaScript and CSS files combined to one file."
415+
"Flush Static Files Cache", "Flush Static Files Cache"
416+
"Preprocessed view files and static files", "Preprocessed view files and static files"
415417
Catalog,Catalog
416418
JavaScript/CSS,JavaScript/CSS
417419
"JavaScript/CSS Cache","JavaScript/CSS Cache"

app/code/Magento/Backend/view/adminhtml/templates/system/cache/additional.phtml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,28 @@
99
<span><?php echo __('Additional Cache Management') ?></span>
1010
</div>
1111
<div class="field">
12-
<button onclick="setLocation('<?php echo $block->getCleanImagesUrl()?>')" type="button">
12+
<button onclick="setLocation('<?php echo $block->getCleanImagesUrl() ?>')" type="button">
1313
<?php echo __('Flush Catalog Images Cache') ?>
1414
</button>
15-
<label class="label"><?php echo __('Pregenerated product images files')?></label>
15+
<label class="label"><?php echo __('Pregenerated product images files') ?></label>
1616
</div>
1717
<div class="field">
18-
<button onclick="setLocation('<?php echo $block->getCleanMediaUrl()?>')" type="button">
18+
<button onclick="setLocation('<?php echo $block->getCleanMediaUrl() ?>')" type="button">
1919
<?php echo __('Flush JavaScript/CSS Cache') ?>
2020
</button>
21-
<label class="label"><?php echo __('Themes JavaScript and CSS files combined to one file.')?></label>
21+
<label class="label"><?php echo __('Themes JavaScript and CSS files combined to one file.') ?></label>
2222
</div>
23+
<?php
24+
if (!$block->isInProductionMode()):
25+
?>
26+
<div class="field">
27+
<button onclick="setLocation('<?php echo $block->getCleanStaticFilesUrl() ?>')" type="button">
28+
<?php echo __('Flush Static Files Cache') ?>
29+
</button>
30+
<label class="label"><?php echo __('Preprocessed view files and static files') ?></label>
31+
</div>
32+
<?php
33+
endif;
34+
?>
2335
<?php echo $block->getChildHtml(); ?>
2436
</div>

app/code/Magento/Config/Block/System/Config/Form/Field/Datetime.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class Datetime extends \Magento\Config\Block\System\Config\Form\Field
1515
/**
1616
* @param AbstractElement $element
1717
* @return string
18+
* @codeCoverageIgnore
1819
*/
1920
protected function _getElementHtml(AbstractElement $element)
2021
{

0 commit comments

Comments
 (0)