Make Chrly's domain configurable

This commit is contained in:
ErickSkrauch 2021-03-04 05:58:07 +01:00
parent 163bbe68a2
commit bd168808b2
5 changed files with 13 additions and 5 deletions

View File

@ -13,6 +13,7 @@ JWT_PRIVATE_PEM_LOCATION=
JWT_PUBLIC_PEM_LOCATION=
## External services
CHRLY_HOST=skinsystem.ely.by
RECAPTCHA_PUBLIC=
RECAPTCHA_SECRET=
SENTRY_DSN=

View File

@ -26,7 +26,7 @@ return [
};
},
common\components\SkinsSystemApi::class => function() {
return new class extends common\components\SkinsSystemApi {
return new class('http://chrly.ely.by') extends common\components\SkinsSystemApi {
public function textures(string $username): ?array {
return [
'SKIN' => [

View File

@ -10,10 +10,14 @@ use Yii;
// TODO: convert to complete Chrly client library
class SkinsSystemApi {
private const BASE_DOMAIN = 'http://skinsystem.ely.by';
private string $baseDomain;
private ?ClientInterface $client = null;
public function __construct(string $baseDomain) {
$this->baseDomain = $baseDomain;
}
/**
* @param string $username
* @throws \GuzzleHttp\Exception\GuzzleException
@ -69,7 +73,7 @@ class SkinsSystemApi {
}
private function buildUrl(string $url): string {
return static::BASE_DOMAIN . $url;
return $this->baseDomain . $url;
}
private function getClient(): ClientInterface {

View File

@ -7,7 +7,7 @@ return [
],
'components' => [
'cache' => [
'class' => \yii\caching\FileCache::class,
'class' => yii\caching\FileCache::class,
],
'security' => [
// It's allows us to increase tests speed by decreasing password hashing algorithm complexity

View File

@ -19,7 +19,10 @@ return [
'singletons' => [
GuzzleHttp\ClientInterface::class => GuzzleHttp\Client::class,
Ely\Mojang\Api::class => Ely\Mojang\Api::class,
common\components\SkinsSystemApi::class => common\components\SkinsSystemApi::class,
common\components\SkinsSystemApi::class => [
'class' => common\components\SkinsSystemApi::class,
'__construct()' => 'http://' . (getenv('CHRLY_HOST') ?: 'skinsystem.ely.by'),
],
],
],
'components' => [