mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-04 23:42:34 +00:00
Merge (#127)
This commit is contained in:
20
app/SSH/HasScripts.php
Normal file
20
app/SSH/HasScripts.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\SSH;
|
||||
|
||||
use ReflectionClass;
|
||||
|
||||
trait HasScripts
|
||||
{
|
||||
private function getScript(string $name, array $vars = []): string
|
||||
{
|
||||
$reflector = new ReflectionClass($this);
|
||||
$scriptsDir = dirname($reflector->getFileName()).'/scripts';
|
||||
$script = file_get_contents($scriptsDir.'/'.$name);
|
||||
foreach ($vars as $key => $value) {
|
||||
$script = str_replace('__'.$key.'__', $value, $script);
|
||||
}
|
||||
|
||||
return $script;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user