vito/app/SSH/HasScripts.php
Saeed Vaziry 428140b931
refactoring (#116)
- refactoring architecture
- fix incomplete ssh logs
- code editor for scripts in the app
- remove Jobs and SSHCommands
2024-03-14 20:03:43 +01:00

21 lines
478 B
PHP

<?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;
}
}