| @@ 213-233 (lines=21) @@ | ||
| 210 | * @param string $file A path to a file relative to the application's root |
|
| 211 | * @return void |
|
| 212 | */ |
|
| 213 | public static function setSecuritySaltInFile($dir, $io, $newKey, $file) |
|
| 214 | { |
|
| 215 | $config = $dir . '/config/' . $file; |
|
| 216 | $content = file_get_contents($config); |
|
| 217 | ||
| 218 | $content = str_replace('__SALT__', $newKey, $content, $count); |
|
| 219 | ||
| 220 | if ($count == 0) { |
|
| 221 | $io->write('No Security.salt placeholder to replace.'); |
|
| 222 | ||
| 223 | return; |
|
| 224 | } |
|
| 225 | ||
| 226 | $result = file_put_contents($config, $content); |
|
| 227 | if ($result) { |
|
| 228 | $io->write('Updated Security.salt value in config/' . $file); |
|
| 229 | ||
| 230 | return; |
|
| 231 | } |
|
| 232 | $io->write('Unable to update Security.salt value.'); |
|
| 233 | } |
|
| 234 | ||
| 235 | /** |
|
| 236 | * Set the APP_NAME value in a given file |
|
| @@ 244-263 (lines=20) @@ | ||
| 241 | * @param string $file A path to a file relative to the application's root |
|
| 242 | * @return void |
|
| 243 | */ |
|
| 244 | public static function setAppNameInFile($dir, $io, $appName, $file) |
|
| 245 | { |
|
| 246 | $config = $dir . '/config/' . $file; |
|
| 247 | $content = file_get_contents($config); |
|
| 248 | $content = str_replace('__APP_NAME__', $appName, $content, $count); |
|
| 249 | ||
| 250 | if ($count == 0) { |
|
| 251 | $io->write('No __APP_NAME__ placeholder to replace.'); |
|
| 252 | ||
| 253 | return; |
|
| 254 | } |
|
| 255 | ||
| 256 | $result = file_put_contents($config, $content); |
|
| 257 | if ($result) { |
|
| 258 | $io->write('Updated __APP_NAME__ value in config/' . $file); |
|
| 259 | ||
| 260 | return; |
|
| 261 | } |
|
| 262 | $io->write('Unable to update __APP_NAME__ value.'); |
|
| 263 | } |
|
| 264 | } |
|
| 265 | ||