Skip to content

LeagueAPI: StaticData linking

Daniel Dolejška edited this page Dec 13, 2018 · 8 revisions

Version v3.0.0-rc.1

This feature allows you to automatically link StaticData related to your request. This feature uses StaticData loaded through DataDragonAPI - it either requires DataDragonAPI to be initialized or LeagueAPI::SET_DATADRAGON_INIT option set to true. For more information about DataDragonAPI initialization by LeagueAPI please see StaticData endpoints page.

Settings key Data type Info / Possible values
LeagueAPI::SET_STATICDATA_LINKING bool true, false
LeagueAPI::SET_STATICDATA_LOCALE string Optional. Language in which will will static data be returned. Supports only languages supported by region.
LeagueAPI::SET_STATICDATA_VERSION string Optional. Game version - when not provided latest version is used. You can get version list using getStaticVersions function.

Only objects shown in table below will be used for automatic static data linking.

Linkable object Link target
Objects\BannedChampion StaticChampion
Objects\ChampionMasteryDto StaticChampion
Objects\CurrentGameParticipant StaticChampion
Objects\MatchReferenceDto StaticChampion
Objects\Participant StaticChampion
Objects\ParticipantDto StaticChampion
Objects\TeamBansDto StaticChampion

Library initialization

use RiotAPI\LeagueAPI\LeagueAPI;

$api = new LeagueAPI([
	// ...
	LeagueAPI::SET_STATICDATA_LINKING => true,
	LeagueAPI::SET_DATADRAGON_INIT    => true,
	// ...
]);

And from now on, StaticData will be automatically linked to some specific objects listed above. You can easily access StaticData properties for these objects like this (this specific example no longer works, but StaticData linking feature still works the same way):

//  ...

//  this call returns Objects\ChampionDto
$champion = $api->getChampionById(61);

//  accessing Objects\ChampionDto's property
echo $champion->id; // 61
echo $champion->freeToPlay; // false
echo $champion->rankedPlayEnabled; // true

//  accessing static data property by magic method
//  (this will only work when static data property name
//    you want to access is not already in use by original object)
echo $champion->name; // Orianna

//  accessing static data through special property
echo $champion->staticData->name; // Orianna