Skip to content

Commit ba69e2d

Browse files
author
Christian Blanquera
committed
Merge branch '2.2' of https://github.com/CradlePHP/cradle-developer into 2.2
2 parents ae401d1 + f0d4fa9 commit ba69e2d

1 file changed

Lines changed: 28 additions & 2 deletions

File tree

src/events/install.php

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,19 +114,45 @@
114114
}
115115
}
116116

117+
//check for sample files
118+
$fileName = trim($path, '.php');
119+
$sampleFile = $fileName . '.sample.php';
120+
$sampleFilePath = $cwd . '/config/' . $sampleFile;
121+
122+
if (file_exists($sampleFilePath) && !$force) {
123+
CommandLine::system('Sample file found for '. $path);
124+
$answer = CommandLine::input('Use sample file for ' . $path . '?(y)', 'y');
125+
if ($answer !== 'y') {
126+
CommandLine::system('Skipping...');
127+
continue;
128+
}
129+
130+
$contents = file_get_contents($sampleFilePath);
131+
$contents = str_replace('<DATABASE HOST>', $host, $contents);
132+
$contents = str_replace('<DATABASE NAME>', $name, $contents);
133+
$contents = str_replace('<DATABASE USER>', $user, $contents);
134+
$contents = str_replace('<DATABASE PASS>', $pass, $contents);
135+
136+
file_put_contents($destination, $contents);
137+
$config = include $destination;
138+
139+
$this->package('global')->service(null);
140+
$this->package('global')->config(basename($path, '.php'), $config);
141+
continue;
142+
}
143+
117144
$contents = file_get_contents($source);
118145
$contents = str_replace('<DATABASE HOST>', $host, $contents);
119146
$contents = str_replace('<DATABASE NAME>', $name, $contents);
120147
$contents = str_replace('<DATABASE USER>', $user, $contents);
121148
$contents = str_replace('<DATABASE PASS>', $pass, $contents);
122149

123150
file_put_contents($destination, $contents);
124-
151+
125152
$config = include $destination;
126153

127154
$this->package('global')->service(null);
128155
$this->package('global')->config(basename($path, '.php'), $config);
129-
130156
}
131157
}
132158

0 commit comments

Comments
 (0)