2023-04-17 07:15:47 -04:00
|
|
|
<?php
|
|
|
|
|
2023-09-07 10:17:04 -04:00
|
|
|
namespace Pterodactyl\BlueprintFramework\Services\VariableService;
|
2023-04-17 07:15:47 -04:00
|
|
|
use Pterodactyl\Contracts\Repository\SettingsRepositoryInterface;
|
2023-09-07 10:24:28 -04:00
|
|
|
use Pterodactyl\BlueprintFramework\Services\PlaceholderService\BlueprintPlaceholderService;
|
2023-04-17 07:15:47 -04:00
|
|
|
|
|
|
|
class BlueprintVariableService
|
|
|
|
{
|
2023-09-07 10:17:04 -04:00
|
|
|
// Construct core
|
2023-06-20 12:08:25 -04:00
|
|
|
public function __construct(
|
|
|
|
private SettingsRepositoryInterface $settings,
|
|
|
|
private BlueprintPlaceholderService $blueprintplaceholderservice,
|
|
|
|
) {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// $bp->serve()
|
|
|
|
// $bp->isInstalled()
|
|
|
|
// $bp->version()
|
|
|
|
// $bp->dbGet('db::record')
|
|
|
|
// $bp->dbSet('db::record', 'value')
|
2023-07-16 14:28:38 -04:00
|
|
|
// $bp->config('item', value);
|
2023-06-20 12:08:25 -04:00
|
|
|
public function serve(): void {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function version(): string {
|
|
|
|
return $this->blueprintplaceholderservice->version();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isInstalled(): string {
|
|
|
|
return $this->blueprintplaceholderservice->installed();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function dbGet($key): string {
|
|
|
|
$a = $this->settings->get("blueprint::".$key);
|
|
|
|
if (!$a) {
|
|
|
|
return "";
|
|
|
|
} else {
|
|
|
|
return $a;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
public function dbSet($key, $value): void {
|
|
|
|
$this->settings->set('blueprint::' . $key, $value);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-07-16 14:28:38 -04:00
|
|
|
public function config($item, $value): string|null {
|
2023-07-25 16:42:32 -04:00
|
|
|
return shell_exec("cd ".escapeshellarg($this->blueprintplaceholderservice->folder()).";c$item=$value bash blueprint.sh -config");
|
2023-06-20 12:08:25 -04:00
|
|
|
}
|
2023-06-18 10:37:46 -04:00
|
|
|
}
|