Files
pterodactyl-panel/app/Actions/Databases/DeleteDatabase.php
T
6c0413e39b Start 2.0 development
Co-authored-by: Anthony <anthony@infraly.co>
Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
2026-10-05 18:10:18 -04:00

32 lines
919 B
PHP

<?php
declare(strict_types=1);
namespace Pterodactyl\Actions\Databases;
use Exception;
use Pterodactyl\Contracts\Databases\DeletesDatabases;
use Pterodactyl\Extensions\DynamicDatabaseConnection;
use Pterodactyl\Models\Database;
use Pterodactyl\Services\Databases\DatabaseHostGateway;
final readonly class DeleteDatabase implements DeletesDatabases
{
public function __construct(
private DynamicDatabaseConnection $dynamic,
private DatabaseHostGateway $gateway,
) {}
/** @throws Exception */
public function delete(Database $database): ?bool
{
$this->dynamic->set('dynamic', $database->relationLoaded('host') ? $database->host : $database->database_host_id);
$this->gateway->dropDatabase($database->database);
$this->gateway->dropUser($database->username, $database->remote);
$this->gateway->flush();
return $database->delete();
}
}