Skip to content

Commit b5cf954

Browse files
author
Christian Blanquera
committed
using basename instead of trim, check the php docs on trim
1 parent ba69e2d commit b5cf954

1 file changed

Lines changed: 13 additions & 16 deletions

File tree

src/events/install.php

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -115,30 +115,27 @@
115115
}
116116

117117
//check for sample files
118-
$fileName = trim($path, '.php');
118+
$fileName = basename($path, '.php');
119119
$sampleFile = $fileName . '.sample.php';
120120
$sampleFilePath = $cwd . '/config/' . $sampleFile;
121121

122122
if (file_exists($sampleFilePath) && !$force) {
123123
CommandLine::system('Sample file found for '. $path);
124124
$answer = CommandLine::input('Use sample file for ' . $path . '?(y)', 'y');
125-
if ($answer !== 'y') {
126-
CommandLine::system('Skipping...');
125+
if ($answer === 'y') {
126+
$contents = file_get_contents($sampleFilePath);
127+
$contents = str_replace('<DATABASE HOST>', $host, $contents);
128+
$contents = str_replace('<DATABASE NAME>', $name, $contents);
129+
$contents = str_replace('<DATABASE USER>', $user, $contents);
130+
$contents = str_replace('<DATABASE PASS>', $pass, $contents);
131+
132+
file_put_contents($destination, $contents);
133+
$config = include $destination;
134+
135+
$this->package('global')->service(null);
136+
$this->package('global')->config(basename($path, '.php'), $config);
127137
continue;
128138
}
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;
142139
}
143140

144141
$contents = file_get_contents($source);

0 commit comments

Comments
 (0)