Skip to content

Commit 7e6a9cd

Browse files
Merge pull request #57 from dennisinteractive/29770_dc_upgrade
Get profile from settings.php if possible
2 parents 22620e3 + 64b40d3 commit 7e6a9cd

File tree

2 files changed

+33
-13
lines changed

2 files changed

+33
-13
lines changed

src/Command/Site/AbstractCommand.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -414,18 +414,6 @@ protected function setProfile(InputInterface $input) {
414414
// Use config from parameter.
415415
$this->profile = $input->getArgument('profile');
416416
}
417-
elseif (isset($this->config['profile'])) {
418-
// Use config from ~/.console/sites/{site}.yml.
419-
$this->profile = $this->config['profile'];
420-
}
421-
else {
422-
$this->profile = 'config_installer';
423-
}
424-
425-
// Update input.
426-
if ($input->hasArgument('profile')) {
427-
$input->setArgument('profile', $this->profile);
428-
}
429417

430418
return $this->profile;
431419
}

src/Command/Site/BuildCommand.php

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ protected function configure() {
8181
InputOption::VALUE_OPTIONAL,
8282
'Specify which branch to build if different than the global branch found in sites.yml'
8383
);
84+
$this->addOption(
85+
'profile',
86+
'',
87+
InputOption::VALUE_NONE,
88+
'Which profile to use. i.e. standard'
89+
);
8490
$this->addOption(
8591
'skip',
8692
'',
@@ -105,6 +111,7 @@ protected function interact(InputInterface $input, OutputInterface $output) {
105111
}
106112
// Trim input.
107113
$this->skip = array_map('trim', $this->skip);
114+
108115
}
109116

110117
/**
@@ -119,12 +126,36 @@ protected function execute(InputInterface $input, OutputInterface $output) {
119126
$this->addCheckoutCommand();
120127
$this->runList();
121128

129+
$this->setSiteRoot();
130+
131+
$profile = $input->getOption('profile');
132+
// Try to get the profile from settings.php.
133+
if (!$profile) {
134+
$settingsPhp = $this->getSiteRoot() . 'settings.php';
135+
if (file_exists($settingsPhp)) {
136+
$regex = '|\$settings\[\'install_profile\'\] = \'(\w+)\'|';
137+
$contents = file_get_contents($settingsPhp);
138+
preg_match($regex, $contents, $matches);
139+
if (!empty($matches)) {
140+
$profile = $matches[1];
141+
}
142+
}
143+
}
144+
// Ask for user input.
145+
if (!$profile) {
146+
$profile = $this->getIo()->ask(
147+
$this->trans('Which profile would you like to install?'),
148+
'standard'
149+
);
150+
}
151+
$this->profile = $profile;
152+
$input->setOption('profile', $profile);
153+
122154
// Run compose now because we need to have core to set the site root.
123155
$this->addComposeMakeCommand();
124156
$this->runList();
125157

126158
// Add entry on sites.php.
127-
$this->setSiteRoot();
128159
$this->addSitesPhp();
129160

130161
// Queue other commands.
@@ -354,6 +385,7 @@ private function addDbImportCommand() {
354385
'command' => 'site:db:import',
355386
'arguments' => array(
356387
'name' => $this->siteName,
388+
'profile' => $this->profile,
357389
)
358390
);
359391
}

0 commit comments

Comments
 (0)