feat: fetch LolEsportOfficialAPI Leagues
This commit is contained in:
parent
79903465b2
commit
6d482d9370
|
|
@ -19,6 +19,14 @@ interface LolEsportOfficialAPIEngine
|
|||
*/
|
||||
public function getTeams();
|
||||
|
||||
/**
|
||||
* @return array<{
|
||||
* id: string,
|
||||
* slug: string,
|
||||
* name: string,
|
||||
* region: string,
|
||||
* }>
|
||||
*/
|
||||
public function getLeagues();
|
||||
|
||||
public function getSeasons(); // "Tournament"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace App\Application\ReadModel;
|
||||
|
||||
readonly class League
|
||||
{
|
||||
public function __construct(
|
||||
public string $id,
|
||||
public string $providerId,
|
||||
public string $providerLeagueId,
|
||||
public string $name,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
|
@ -3,8 +3,10 @@
|
|||
namespace App\Application\UseCase\LeagueOfLegends;
|
||||
|
||||
use App\Application\LolEsportOfficialAPI\LolEsportOfficialAPIEngine;
|
||||
use App\Application\ReadModel\League as LeagueRM;
|
||||
use App\Application\ReadModel\Provider as ProviderRM;
|
||||
use App\Application\ReadModel\Team as TeamRM;
|
||||
use App\Domain\Entity\League;
|
||||
use App\Domain\Entity\Provider;
|
||||
use App\Domain\Entity\Team;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
|
@ -61,6 +63,29 @@ class FetchLolEsportOfficialAPISchedule
|
|||
}
|
||||
|
||||
// Fetch League
|
||||
$lolEsportOfficialAPILeagues = $this->lolEsportOfficialAPIEngine->getLeagues();
|
||||
$leaguesRM = $this->entityManager->getRepository(LeagueRM::class)->findBy(['providerId' => $providerRM->id]);
|
||||
$leaguesRMWithId = [];
|
||||
foreach ($leaguesRM as $league) {
|
||||
$leaguesRMWithId[$league->providerLeagueId] = $league;
|
||||
}
|
||||
|
||||
foreach ($lolEsportOfficialAPILeagues as $league) {
|
||||
if (!isset($leaguesRMWithId[$league['id']])) {
|
||||
// Create Team
|
||||
$leagueEntity = new League();
|
||||
$leagueEntity->create(
|
||||
$provider,
|
||||
$league['id'],
|
||||
$league['name'],
|
||||
);
|
||||
|
||||
$this->entityManager->persist($leagueEntity);
|
||||
continue;
|
||||
}
|
||||
|
||||
// check for renaming?
|
||||
}
|
||||
|
||||
// Fetch Season (Tournament). Need to be maped to a league from name if fetch all, can be fetch by league
|
||||
// add endDate
|
||||
|
|
|
|||
|
|
@ -21,9 +21,16 @@ class FakeLolEsportOfficialAPIEngine implements LolEsportOfficialAPIEngine
|
|||
], $fake_lolesport_official_api_lol_teams["data"]["teams"]);
|
||||
}
|
||||
|
||||
public function getLeagues()
|
||||
public function getLeagues(): array
|
||||
{
|
||||
// TODO: Implement getLeagues() method.
|
||||
$fake_lolesport_official_api_lol_leagues = json_decode(file_get_contents(__DIR__ . '/Fixtures/lolesport_official_api_lol_leagues_21_12_2025.json'), true);
|
||||
|
||||
return array_map(fn ($league) => [
|
||||
'id' => $league['id'],
|
||||
'slug' => $league['slug'],
|
||||
'name' => $league['name'],
|
||||
'region' => $league['region'],
|
||||
], $fake_lolesport_official_api_lol_leagues['data']['leagues']);
|
||||
}
|
||||
|
||||
public function getSeasons()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,486 @@
|
|||
{
|
||||
"data": {
|
||||
"leagues": [
|
||||
{
|
||||
"id": "98767975604431411",
|
||||
"slug": "worlds",
|
||||
"name": "Worlds",
|
||||
"region": "INTERNATIONAL",
|
||||
"image": "http://static.lolesports.com/leagues/1592594612171_WorldsDarkBG.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 0,
|
||||
"status": "force_selected"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "98767991325878492",
|
||||
"slug": "msi",
|
||||
"name": "MSI",
|
||||
"region": "INTERNATIONAL",
|
||||
"image": "http://static.lolesports.com/leagues/1592594634248_MSIDarkBG.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 1,
|
||||
"status": "force_selected"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "113464388705111224",
|
||||
"slug": "first_stand",
|
||||
"name": "First Stand",
|
||||
"region": "INTERNATIONAL",
|
||||
"image": "http://static.lolesports.com/leagues/1740042025201_RG_LOL_FIRST_STAND_LOGO_VOLT_ALPHA.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 2,
|
||||
"status": "force_selected"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "98767991299243165",
|
||||
"slug": "lcs",
|
||||
"name": "LCS",
|
||||
"region": "NORTH AMERICA",
|
||||
"image": "http://static.lolesports.com/leagues/1706356907418_LCSNew-01-FullonDark.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 0,
|
||||
"status": "selected"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "98767991332355509",
|
||||
"slug": "cblol-brazil",
|
||||
"name": "CBLOL",
|
||||
"region": "BRAZIL",
|
||||
"image": "http://static.lolesports.com/leagues/cblol-logo-symbol-offwhite.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 1,
|
||||
"status": "selected"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "98767991302996019",
|
||||
"slug": "lec",
|
||||
"name": "LEC",
|
||||
"region": "EMEA",
|
||||
"image": "http://static.lolesports.com/leagues/1592516184297_LEC-01-FullonDark.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 2,
|
||||
"status": "selected"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "98767991310872058",
|
||||
"slug": "lck",
|
||||
"name": "LCK",
|
||||
"region": "KOREA",
|
||||
"image": "http://static.lolesports.com/leagues/lck-color-on-black.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 0,
|
||||
"status": "not_selected"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "98767991314006698",
|
||||
"slug": "lpl",
|
||||
"name": "LPL",
|
||||
"region": "CHINA",
|
||||
"image": "http://static.lolesports.com/leagues/1592516115322_LPL-01-FullonDark.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 1,
|
||||
"status": "not_selected"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "113476371197627891",
|
||||
"slug": "lcp",
|
||||
"name": "LCP",
|
||||
"region": "PACIFIC",
|
||||
"image": "http://static.lolesports.com/leagues/1733468139601_lcp-color-golden.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 2,
|
||||
"status": "not_selected"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "109511549831443335",
|
||||
"slug": "nacl",
|
||||
"name": "NACL",
|
||||
"region": "NORTH AMERICA",
|
||||
"image": "http://static.lolesports.com/leagues/1740390007442_FULL_COLOR_FOR_DARK_BG.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 3,
|
||||
"status": "not_selected"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "100695891328981122",
|
||||
"slug": "emea_masters",
|
||||
"name": "EMEA Masters",
|
||||
"region": "EMEA",
|
||||
"image": "http://static.lolesports.com/leagues/1669375535108_EM_Icon_Green1.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 4,
|
||||
"status": "not_selected"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "98767991349978712",
|
||||
"slug": "ljl-japan",
|
||||
"name": "LJL",
|
||||
"region": "JAPAN",
|
||||
"image": "http://static.lolesports.com/leagues/1733997208721_LJL_icon_white_724px.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 5,
|
||||
"status": "not_selected"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "98767991343597634",
|
||||
"slug": "turkiye-sampiyonluk-ligi",
|
||||
"name": "TCL",
|
||||
"region": "EMEA",
|
||||
"image": "http://static.lolesports.com/leagues/1738338347640_ampiyonlukLigi-AMBLEM.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 6,
|
||||
"status": "not_selected"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "105266098308571975",
|
||||
"slug": "nlc",
|
||||
"name": "NLC",
|
||||
"region": "EMEA",
|
||||
"image": "http://static.lolesports.com/leagues/1641490922073_nlc_logo.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 7,
|
||||
"status": "not_selected"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "105266103462388553",
|
||||
"slug": "lfl",
|
||||
"name": "La Ligue Française",
|
||||
"region": "EMEA",
|
||||
"image": "http://static.lolesports.com/leagues/LFL_Logo_2020_black1.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 8,
|
||||
"status": "not_selected"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "107407335299756365",
|
||||
"slug": "roadoflegends",
|
||||
"name": "Road of Legends",
|
||||
"region": "EMEA",
|
||||
"image": "http://static.lolesports.com/leagues/1737450944766_ROL_DARKBG.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 9,
|
||||
"status": "not_selected"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "105266101075764040",
|
||||
"slug": "liga_portuguesa",
|
||||
"name": "Liga Portuguesa",
|
||||
"region": "EMEA",
|
||||
"image": "http://static.lolesports.com/leagues/1649884876085_LPLOL_2021_ISO_G-c389e9ae85c243e4f76a8028bbd9ca1609c2d12bc47c3709a9250d1b3ca43f58.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 10,
|
||||
"status": "not_selected"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "105266094998946936",
|
||||
"slug": "lit",
|
||||
"name": "LoL Italian Tournament",
|
||||
"region": "EMEA",
|
||||
"image": "http://static.lolesports.com/leagues/1703058345246_IMG_4673.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 11,
|
||||
"status": "not_selected"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "113673877956508505",
|
||||
"slug": "rift_legends",
|
||||
"name": "Rift Legends",
|
||||
"region": "EMEA",
|
||||
"image": "http://static.lolesports.com/leagues/1736963779891_Logo_short_lightRL__.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 12,
|
||||
"status": "not_selected"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "105266074488398661",
|
||||
"slug": "superliga",
|
||||
"name": "SuperLiga",
|
||||
"region": "EMEA",
|
||||
"image": "http://static.lolesports.com/leagues/SL21-V-white.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 13,
|
||||
"status": "not_selected"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "105266091639104326",
|
||||
"slug": "primeleague",
|
||||
"name": "Prime League",
|
||||
"region": "EMEA",
|
||||
"image": "http://static.lolesports.com/leagues/PrimeLeagueResized.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 14,
|
||||
"status": "not_selected"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "105266106309666619",
|
||||
"slug": "hitpoint_masters",
|
||||
"name": "Hitpoint Masters",
|
||||
"region": "EMEA",
|
||||
"image": "http://static.lolesports.com/leagues/1641465237186_HM_white.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 15,
|
||||
"status": "not_selected"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "105266111679554379",
|
||||
"slug": "esports_balkan_league",
|
||||
"name": "Esports Balkan League",
|
||||
"region": "EMEA",
|
||||
"image": "http://static.lolesports.com/leagues/1625735031226_ebl_crest-whitePNG.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 16,
|
||||
"status": "not_selected"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "105266108767593290",
|
||||
"slug": "hellenic_legends_league",
|
||||
"name": "Hellenic Legends League",
|
||||
"region": "EMEA",
|
||||
"image": "http://static.lolesports.com/leagues/1736361775356_HLL_FULL_COLOUR_DARKBG.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 17,
|
||||
"status": "not_selected"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "109545772895506419",
|
||||
"slug": "arabian_league",
|
||||
"name": "Arabian League",
|
||||
"region": "EMEA",
|
||||
"image": "http://static.lolesports.com/leagues/1738573749768_GoldAL.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 18,
|
||||
"status": "not_selected"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "98767991335774713",
|
||||
"slug": "lck_challengers_league",
|
||||
"name": "LCK Challengers",
|
||||
"region": "KOREA",
|
||||
"image": "http://static.lolesports.com/leagues/lck-cl-white.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 19,
|
||||
"status": "not_selected"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "105549980953490846",
|
||||
"slug": "cd",
|
||||
"name": "Circuito Desafiante",
|
||||
"region": "BRAZIL",
|
||||
"image": "http://static.lolesports.com/leagues/1739883216140_CIRCUITO_DESAFIANTE_COLOR_ORANGE.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 20,
|
||||
"status": "not_selected"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "104366947889790212",
|
||||
"slug": "pcs",
|
||||
"name": "PCS",
|
||||
"region": "HONG KONG, MACAU, TAIWAN",
|
||||
"image": "http://static.lolesports.com/leagues/1592515942679_PCS-01-FullonDark.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 21,
|
||||
"status": "not_selected"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "110371976858004491",
|
||||
"slug": "north_regional_league",
|
||||
"name": "LRN",
|
||||
"region": "LATIN AMERICA NORTH",
|
||||
"image": "http://static.lolesports.com/leagues/1742461971444_FULL_COLOR_FOR_DARK_BG1.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 22,
|
||||
"status": "not_selected"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "110372322609949919",
|
||||
"slug": "south_regional_league",
|
||||
"name": "LRS",
|
||||
"region": "LATIN AMERICA SOUTH",
|
||||
"image": "http://static.lolesports.com/leagues/1742460115671_FULL_COLOR_FOR_DARK_BG.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 23,
|
||||
"status": "not_selected"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "108001239847565215",
|
||||
"slug": "tft_esports",
|
||||
"name": "TFT Esports ",
|
||||
"region": "INTERNATIONAL",
|
||||
"image": "http://static.lolesports.com/leagues/1723029828764_TFT_GRADIENT_2.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 24,
|
||||
"status": "not_selected"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "113475149040947852",
|
||||
"slug": "lta_cross",
|
||||
"name": "LTA Cross-Conference",
|
||||
"region": "AMERICAS",
|
||||
"image": "http://static.lolesports.com/leagues/1731566966819_LTA-LOGO-LightGold_RGB2000px.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 4,
|
||||
"status": "hidden"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "101382741235120470",
|
||||
"slug": "lla",
|
||||
"name": "LLA",
|
||||
"region": "LATIN AMERICA",
|
||||
"image": "http://static.lolesports.com/leagues/1592516315279_LLA-01-FullonDark.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 6,
|
||||
"status": "hidden"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "105709090213554609",
|
||||
"slug": "lco",
|
||||
"name": "LCO",
|
||||
"region": "OCEANIA",
|
||||
"image": "http://static.lolesports.com/leagues/lco-color-white.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 18,
|
||||
"status": "hidden"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "107213827295848783",
|
||||
"slug": "vcs",
|
||||
"name": "VCS",
|
||||
"region": "VIETNAM",
|
||||
"image": "http://static.lolesports.com/leagues/1677578094811_VCS_SYMBOL_TITANIUM_RGB.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 20,
|
||||
"status": "hidden"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "110988878756156222",
|
||||
"slug": "wqs",
|
||||
"name": "Worlds Qualifying Series",
|
||||
"region": "INTERNATIONAL",
|
||||
"image": "http://static.lolesports.com/leagues/1693555886600_lolesports_icon_ice-01.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 30,
|
||||
"status": "hidden"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "111102022734849553",
|
||||
"slug": "duelo_de_reyes",
|
||||
"name": "King's Duel",
|
||||
"region": "LATIN AMERICA",
|
||||
"image": "http://static.lolesports.com/leagues/1695282324552_B.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 58,
|
||||
"status": "hidden"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "113470291645289904",
|
||||
"slug": "lta_n",
|
||||
"name": "LTA North",
|
||||
"region": "AMERICAS",
|
||||
"image": "http://static.lolesports.com/leagues/1731566778368_LTANORTH-LOGO_Blue_RGB2000px.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 63,
|
||||
"status": "hidden"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "113475181634818701",
|
||||
"slug": "lta_s",
|
||||
"name": "LTA South",
|
||||
"region": "AMERICAS",
|
||||
"image": "http://static.lolesports.com/leagues/1731566868757_LTASOUTH-LOGO_Red_RGB2000px.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 64,
|
||||
"status": "hidden"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "98767991355908944",
|
||||
"slug": "lcl",
|
||||
"name": "LCL",
|
||||
"region": "COMMONWEALTH OF INDEPENDENT STATES",
|
||||
"image": "http://static.lolesports.com/leagues/1593016885758_LCL-01-FullonDark.png",
|
||||
"priority": 1,
|
||||
"displayPriority": {
|
||||
"position": 97,
|
||||
"status": "hidden"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
$builder = new Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder($metadata);
|
||||
|
||||
$builder
|
||||
->setReadOnly()
|
||||
->setTable('league')
|
||||
;
|
||||
|
||||
$builder
|
||||
->createField('id', 'uuid')
|
||||
->nullable(false)
|
||||
->makePrimaryKey()
|
||||
->build();
|
||||
|
||||
$builder
|
||||
->createField('providerId', 'uuid')
|
||||
->columnName('provider_id')
|
||||
->nullable(false)
|
||||
->build();
|
||||
|
||||
$builder
|
||||
->createField('providerLeagueId', 'string')
|
||||
->columnName('provider_league_id')
|
||||
->nullable(false)
|
||||
->build();
|
||||
|
||||
$builder
|
||||
->createField('name', 'string')
|
||||
->nullable(false)
|
||||
->build();
|
||||
|
|
@ -15,11 +15,16 @@ $builder
|
|||
->build();
|
||||
|
||||
$builder
|
||||
->createField('providerLeagueId', 'uuid')
|
||||
->createField('providerLeagueId', 'string')
|
||||
->columnName('provider_league_id')
|
||||
->nullable(false)
|
||||
->build();
|
||||
|
||||
$builder
|
||||
->createField('name', 'string')
|
||||
->nullable(false)
|
||||
->build();
|
||||
|
||||
$builder
|
||||
->createManyToOne('provider', 'App\\Domain\\Entity\\Provider')
|
||||
->addJoinColumn('provider_id', 'id', false, false, 'CASCADE')
|
||||
|
|
|
|||
Loading…
Reference in New Issue