diff --git a/src/PropertySuggester/GetSuggestions.php b/src/PropertySuggester/GetSuggestions.php index fd7331c..4e83ff2 100644 --- a/src/PropertySuggester/GetSuggestions.php +++ b/src/PropertySuggester/GetSuggestions.php @@ -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. @@ -31,6 +30,11 @@ class GetSuggestions extends ApiBase { */ private $entityTitleLookup; + /** + * @var string[] + */ + private $languageCodes; + /** * @var SuggesterEngine */ @@ -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 ); @@ -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(