From 39671901f124b1b065ad92d7d4d421228edc9485 Mon Sep 17 00:00:00 2001 From: nmalevanec Date: Wed, 10 Jan 2018 16:25:48 +0200 Subject: [PATCH] magento/magento2#4292: Ability to switch to default mode[forwardport]. --- .../Deploy/Console/Command/SetModeCommand.php | 3 +++ app/code/Magento/Deploy/Model/Mode.php | 19 +++++++++++++++++++ .../Console/Command/SetModeCommandTest.php | 13 ++++++++++++- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Deploy/Console/Command/SetModeCommand.php b/app/code/Magento/Deploy/Console/Command/SetModeCommand.php index c4485656fb884..55b4a4f4f9b6a 100644 --- a/app/code/Magento/Deploy/Console/Command/SetModeCommand.php +++ b/app/code/Magento/Deploy/Console/Command/SetModeCommand.php @@ -101,6 +101,9 @@ protected function execute(InputInterface $input, OutputInterface $output) $modeController->enableProductionMode(); } break; + case State::MODE_DEFAULT: + $modeController->enableDefaultMode(); + break; default: throw new LocalizedException(__('Cannot switch into given mode "%1"', $toMode)); } diff --git a/app/code/Magento/Deploy/Model/Mode.php b/app/code/Magento/Deploy/Model/Mode.php index ba3e8652fd443..990d119e92ee0 100644 --- a/app/code/Magento/Deploy/Model/Mode.php +++ b/app/code/Magento/Deploy/Model/Mode.php @@ -167,6 +167,25 @@ public function enableDeveloperMode() $this->setStoreMode(State::MODE_DEVELOPER); } + /** + * Enable Default mode. + * + * @return void + */ + public function enableDefaultMode() + { + $this->filesystem->cleanupFilesystem( + [ + DirectoryList::CACHE, + DirectoryList::GENERATED_CODE, + DirectoryList::GENERATED_METADATA, + DirectoryList::TMP_MATERIALIZATION_DIR, + DirectoryList::STATIC_VIEW, + ] + ); + $this->setStoreMode(State::MODE_DEFAULT); + } + /** * Get current mode information * diff --git a/app/code/Magento/Deploy/Test/Unit/Console/Command/SetModeCommandTest.php b/app/code/Magento/Deploy/Test/Unit/Console/Command/SetModeCommandTest.php index caa310535f356..33ffbf20c5bd9 100644 --- a/app/code/Magento/Deploy/Test/Unit/Console/Command/SetModeCommandTest.php +++ b/app/code/Magento/Deploy/Test/Unit/Console/Command/SetModeCommandTest.php @@ -7,7 +7,6 @@ use Magento\Deploy\Console\Command\SetModeCommand; use Symfony\Component\Console\Tester\CommandTester; -use Magento\Framework\App\State; /** * @package Magento\Deploy\Test\Unit\Console\Command @@ -67,6 +66,18 @@ public function testSetDeveloperMode() ); } + public function testSetDefaultMode() + { + $this->modeMock->expects($this->once())->method('enableDefaultMode'); + + $tester = new CommandTester($this->command); + $tester->execute(['mode' => 'default']); + $this->assertContains( + "default mode", + $tester->getDisplay() + ); + } + public function testSetProductionSkipCompilation() { $this->modeMock->expects($this->once())->method('enableProductionModeMinimal');