Skip to content

Commit 0818a5d

Browse files
Added feature to not overwrite existing handlers if found in core application (#170)
* Added feature to not overwrite existing handlers * Applied fix from StyleCI * Removed redundent if conditional * Update InjectHandlers.php Co-authored-by: Taylor Otwell <[email protected]>
1 parent 6bef414 commit 0818a5d

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

src/BuildProcess/InjectHandlers.php

+18-4
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ public function __invoke()
3030
$this->files->copy($stubPath.'/runtime.php', $this->appPath.'/runtime.php');
3131
}
3232

33-
$this->files->copy($stubPath.'/cliRuntime.php', $this->appPath.'/cliRuntime.php');
34-
$this->files->copy($stubPath.'/fpmRuntime.php', $this->appPath.'/fpmRuntime.php');
35-
$this->files->copy($stubPath.'/httpRuntime.php', $this->appPath.'/httpRuntime.php');
36-
$this->files->copy($stubPath.'/httpHandler.php', $this->appPath.'/httpHandler.php');
33+
$this->copyMissing($stubPath.'/cliRuntime.php', $this->appPath.'/cliRuntime.php');
34+
$this->copyMissing($stubPath.'/fpmRuntime.php', $this->appPath.'/fpmRuntime.php');
35+
$this->copyMissing($stubPath.'/httpRuntime.php', $this->appPath.'/httpRuntime.php');
36+
$this->copyMissing($stubPath.'/httpHandler.php', $this->appPath.'/httpHandler.php');
3737

3838
if (Manifest::shouldSeparateVendor($this->environment)) {
3939
file_put_contents(
@@ -61,4 +61,18 @@ protected function configureHttpHandler($file)
6161
file_get_contents($file)
6262
);
6363
}
64+
65+
/**
66+
* Copy a file to a new location if that file does not exist.
67+
*
68+
* @param string $from
69+
* @param string $to
70+
* @return void
71+
*/
72+
protected function copyMissing($from, $to)
73+
{
74+
if (! $this->files->exists($to)) {
75+
$this->files->copy($from, $to);
76+
}
77+
}
6478
}

0 commit comments

Comments
 (0)