Files
pterodactyl-panel/app/Providers/HashidsServiceProvider.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

34 lines
1.0 KiB
PHP

<?php
declare(strict_types=1);
namespace Pterodactyl\Providers;
use Illuminate\Contracts\Config\Repository;
use Illuminate\Support\ServiceProvider;
use Pterodactyl\Contracts\Extensions\HashidsInterface;
use Pterodactyl\Extensions\Hashids;
use Pterodactyl\Support\JsonValueGuard;
class HashidsServiceProvider extends ServiceProvider
{
/**
* Register the ability to use Hashids.
*/
public function register(): void
{
$this->app->singleton(function (): HashidsInterface {
$config = $this->app->make(Repository::class);
$length = filter_var($config->get('hashids.length', 0), FILTER_VALIDATE_INT);
return new Hashids(
JsonValueGuard::string($config->get('hashids.salt', '')),
$length === false ? 0 : $length,
JsonValueGuard::string($config->get('hashids.alphabet', 'abcdefghijkmlnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'))
);
});
$this->app->alias(HashidsInterface::class, 'hashids');
}
}