Skip to content

Commit

Permalink
Merge pull request #117 from Wikidata-lib/utils
Browse files Browse the repository at this point in the history
Don't use Wikibase\Utils to get languages for GetSuggestions api module
  • Loading branch information
JanZerebecki committed Feb 20, 2015
2 parents 3b56482 + 235ebad commit f0eb2a1
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/PropertySuggester/GetSuggestions.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use Wikibase\Lib\Store\EntityTitleLookup;
use Wikibase\Repo\WikibaseRepo;
use Wikibase\TermIndex;
use Wikibase\Utils;

/**
* API module to get property suggestions.
Expand All @@ -31,6 +30,11 @@ class GetSuggestions extends ApiBase {
*/
private $entityTitleLookup;

/**
* @var string[]
*/
private $languageCodes;

/**
* @var SuggesterEngine
*/
Expand All @@ -52,10 +56,13 @@ public function __construct( ApiMain $main, $name, $prefix = '' ) {
global $wgPropertySuggesterMinProbability;
global $wgPropertySuggesterClassifyingPropertyIds;

$store = WikibaseRepo::getDefaultInstance()->getStore();
$wikibaseRepo = WikibaseRepo::getDefaultInstance();
$store = $wikibaseRepo->getStore();

$this->termIndex = $store->getTermIndex();
$this->entityLookup = $store->getEntityLookup();
$this->entityTitleLookup = WikibaseRepo::getDefaultInstance()->getEntityTitleLookup();
$this->entityTitleLookup = $wikibaseRepo->getEntityTitleLookup();
$this->languageCodes = $wikibaseRepo->getTermsLanguages()->getLanguages();

$this->suggester = new SimpleSuggester( wfGetLB() );
$this->suggester->setDeprecatedPropertyIds( $wgPropertySuggesterDeprecatedIds );
Expand Down Expand Up @@ -150,7 +157,7 @@ public function getAllowedParams() {
),
'continue' => null,
'language' => array(
ApiBase::PARAM_TYPE => Utils::getLanguageCodes(),
ApiBase::PARAM_TYPE => $this->languageCodes,
ApiBase::PARAM_DFLT => $this->getContext()->getLanguage()->getCode(),
),
'context' => array(
Expand Down

0 comments on commit f0eb2a1

Please sign in to comment.