Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 3967190

Browse files
committed
magento/magento2#4292: Ability to switch to default mode[forwardport].
1 parent e150a7e commit 3967190

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

app/code/Magento/Deploy/Console/Command/SetModeCommand.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
101101
$modeController->enableProductionMode();
102102
}
103103
break;
104+
case State::MODE_DEFAULT:
105+
$modeController->enableDefaultMode();
106+
break;
104107
default:
105108
throw new LocalizedException(__('Cannot switch into given mode "%1"', $toMode));
106109
}

app/code/Magento/Deploy/Model/Mode.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,25 @@ public function enableDeveloperMode()
167167
$this->setStoreMode(State::MODE_DEVELOPER);
168168
}
169169

170+
/**
171+
* Enable Default mode.
172+
*
173+
* @return void
174+
*/
175+
public function enableDefaultMode()
176+
{
177+
$this->filesystem->cleanupFilesystem(
178+
[
179+
DirectoryList::CACHE,
180+
DirectoryList::GENERATED_CODE,
181+
DirectoryList::GENERATED_METADATA,
182+
DirectoryList::TMP_MATERIALIZATION_DIR,
183+
DirectoryList::STATIC_VIEW,
184+
]
185+
);
186+
$this->setStoreMode(State::MODE_DEFAULT);
187+
}
188+
170189
/**
171190
* Get current mode information
172191
*

app/code/Magento/Deploy/Test/Unit/Console/Command/SetModeCommandTest.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
use Magento\Deploy\Console\Command\SetModeCommand;
99
use Symfony\Component\Console\Tester\CommandTester;
10-
use Magento\Framework\App\State;
1110

1211
/**
1312
* @package Magento\Deploy\Test\Unit\Console\Command
@@ -67,6 +66,18 @@ public function testSetDeveloperMode()
6766
);
6867
}
6968

69+
public function testSetDefaultMode()
70+
{
71+
$this->modeMock->expects($this->once())->method('enableDefaultMode');
72+
73+
$tester = new CommandTester($this->command);
74+
$tester->execute(['mode' => 'default']);
75+
$this->assertContains(
76+
"default mode",
77+
$tester->getDisplay()
78+
);
79+
}
80+
7081
public function testSetProductionSkipCompilation()
7182
{
7283
$this->modeMock->expects($this->once())->method('enableProductionModeMinimal');

0 commit comments

Comments
 (0)