mirror of
https://github.com/pterodactyl/panel.git
synced 2026-11-30 11:25:52 -05:00
Co-authored-by: Anthony <anthony@infraly.co> Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
34 lines
1.0 KiB
PHP
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');
|
|
}
|
|
}
|