Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit f83ae6f

Browse files
authored
Allowing Inspector state to be cleared. (#1559)
* Allowing Inspector state to be cleared. * Fixing misleading typo.
1 parent 56587dd commit f83ae6f

File tree

5 files changed

+33
-16
lines changed

5 files changed

+33
-16
lines changed

src/Robo/Blt.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public function configureContainer($container) {
184184
$container->add('executor', Executor::class)
185185
->withArgument('builder');
186186

187-
$container->add('inspector', Inspector::class)
187+
$container->share('inspector', Inspector::class)
188188
->withArgument('executor');
189189

190190
$container->inflector(InspectorAwareInterface::class)

src/Robo/Commands/Blt/DoctorCommand.php

+7-4
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,28 @@ public function doctor() {
2323
&& !$this->getInspector()->isVmCli()) {
2424
$result = $this->executeDoctorInsideVm();
2525
if ($result->wasSuccessful()) {
26-
return $result;
26+
return $result->getExitCode();
2727
}
2828
}
2929

3030
// Try BLT doctor with default alias. This might be a Drupal VM alias.
3131
$alias = $this->getConfigValue('drush.alias');
32+
$this->say('Attempting to run doctor on host machine...');
3233
$result = $this->executeDoctorOnHost($alias);
3334

3435
// If default alias failed, try again using @self alias.
3536
if (!$result->wasSuccessful() && $alias != 'self') {
36-
$this->logger->warning("Unable to run the doctor using @$alias. Trying with @self...");
37+
$this->logger->warning("Unable to run the doctor using alias '@$alias'. Trying with '@self'...");
3738
$this->executeDoctorOnHost('self');
3839
}
3940

4041
// If @self fails, try without any alias.
4142
if (!$result->wasSuccessful() && $alias != '') {
42-
$this->logger->warning("Unable to run the doctor using @self. Trying without alias...");
43+
$this->logger->warning("Unable to run the doctor using alias '@self'. Trying without alias...");
4344
$this->executeDoctorOnHost('');
4445
}
4546

46-
return $result;
47+
return $result->getExitCode();
4748
}
4849

4950
/**
@@ -73,6 +74,8 @@ protected function executeDoctorOnHost($alias) {
7374
->alias($alias)
7475
->uri("")
7576
->includePath($this->getConfigValue('blt.root') . '/drush')
77+
->printOutput(FALSE)
78+
->printMetadata(FALSE)
7679
->run();
7780

7881
return $result;

src/Robo/Commands/Setup/BuildCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class BuildCommand extends BltTasks {
1919
* @aliases setup:all
2020
*/
2121
public function setup() {
22-
$this->say("Setting up local environment for @{$this->getConfigValue('site')}...");
22+
$this->say("Setting up local environment for site '{$this->getConfigValue('site')}'...");
2323
$status_code = $this->invokeCommands([
2424
'setup:build',
2525
'setup:hash-salt',

src/Robo/Inspector/Inspector.php

+23-10
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ class Inspector implements BuilderAwareInterface, ConfigAwareInterface, LoggerAw
3333
*/
3434
protected $executor;
3535

36+
/**
37+
* @var null
38+
*/
39+
protected $isDrupalInstalled = NULL;
40+
41+
/**
42+
* @var null
43+
*/
44+
protected $isMySqlAvailable = NULL;
45+
3646
/**
3747
* The constructor.
3848
*
@@ -43,6 +53,11 @@ public function __construct(Executor $executor) {
4353
$this->executor = $executor;
4454
}
4555

56+
public function clearState() {
57+
$this->isDrupalInstalled = NULL;
58+
$this->isMySqlAvailable = NULL;
59+
}
60+
4661
/**
4762
* Determines if the repository root directory exists.
4863
*
@@ -123,20 +138,19 @@ public function isDrupalSettingsFileValid() {
123138
/**
124139
* Checks that Drupal is installed, caches result.
125140
*
126-
* This method caches its result in state.drupal.installed value.
141+
* This method caches its result in $this->drupalIsInstalled.
127142
*
128143
* @return bool
129144
* TRUE if Drupal is installed.
130145
*/
131146
public function isDrupalInstalled() {
132147
// This will only run once per command. If Drupal is installed mid-command,
133148
// this value needs to be changed.
134-
if (is_null($this->getConfigValue('state.drupal.installed'))) {
135-
$installed = $this->getDrupalInstalled();
136-
$this->getConfig()->set('state.drupal.installed', $installed);
149+
if (is_null($this->isDrupalInstalled)) {
150+
$this->isDrupalInstalled = $this->getDrupalInstalled();
137151
}
138152

139-
return $this->getConfigValue('state.drupal.installed');
153+
return $this->isDrupalInstalled;
140154
}
141155

142156
/**
@@ -171,18 +185,17 @@ public function getDrushStatus() {
171185
/**
172186
* Determines if MySQL is available, caches result.
173187
*
174-
* This method caches its result in state.mysql.available config.
188+
* This method caches its result in $this->mySqlAvailable.
175189
*
176190
* @return bool
177191
* TRUE if MySQL is available.
178192
*/
179193
public function isMySqlAvailable() {
180-
if (is_null($this->getConfigValue('state.mysql.available'))) {
181-
$mysql_available = $this->getMySqlAvailable();
182-
$this->getConfig()->set('state.mysql.available', $mysql_available);
194+
if (is_null($this->isMySqlAvailable)) {
195+
$this->isMySqlAvailable = $this->getMySqlAvailable();
183196
}
184197

185-
return $this->getConfigValue('state.mysql.available');
198+
return $this->isMySqlAvailable;
186199
}
187200

188201
/**

src/Robo/Wizards/SetupWizard.php

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public function wizardInstallDrupal() {
4444
->execute("$bin/blt setup")
4545
->detectInteractive()
4646
->run();
47+
$this->getInspector()->clearState();
4748
}
4849
}
4950
}

0 commit comments

Comments
 (0)