98 $endTime = $this->
microtime() + self::MAX_EXECUTE_SECONDS;
101 $includeCode = isset( $props[
'code'] );
102 $includeBcp47 = isset( $props[
'bcp47'] );
103 $includeDir = isset( $props[
'dir'] );
104 $includeAutonym = isset( $props[
'autonym'] );
105 $includeName = isset( $props[
'name'] );
106 $includeFallbacks = isset( $props[
'fallbacks'] );
107 $includeVariants = isset( $props[
'variants'] );
109 $targetLanguageCode = $this->
getLanguage()->getCode();
112 $availableLanguageCodes = array_keys( $this->languageNameUtils->getLanguageNames(
121 if ( $selectedLanguageCodes === [
'*' ] ) {
122 $languageCodes = $availableLanguageCodes;
124 $languageCodes = array_values( array_intersect(
125 $availableLanguageCodes,
126 $selectedLanguageCodes
128 $unrecognizedCodes = array_values( array_diff(
129 $selectedLanguageCodes,
130 $availableLanguageCodes
132 if ( $unrecognizedCodes !== [] ) {
134 'apiwarn-unrecognizedvalues',
137 count( $unrecognizedCodes ),
145 if ( $continue ===
null ) {
146 $continue = reset( $languageCodes );
154 $result->addArrayType( $rootPath,
'assoc' );
156 foreach ( $languageCodes as $languageCode ) {
157 if ( $languageCode < $continue ) {
162 if ( $now >= $endTime ) {
168 ApiResult::setArrayType( $info,
'assoc' );
170 if ( $includeCode ) {
171 $info[
'code'] = $languageCode;
174 if ( $includeBcp47 ) {
175 $bcp47 = LanguageCode::bcp47( $languageCode );
176 $info[
'bcp47'] = $bcp47;
180 $dir = $this->languageFactory->getLanguage( $languageCode )->getDir();
184 if ( $includeAutonym ) {
185 $autonym = $this->languageNameUtils->getLanguageName(
187 LanguageNameUtils::AUTONYMS,
190 $info[
'autonym'] = $autonym;
193 if ( $includeName ) {
194 $name = $this->languageNameUtils->getLanguageName(
199 $info[
'name'] = $name;
202 if ( $includeFallbacks ) {
203 $fallbacks = $this->languageFallback->getAll(
206 LanguageFallback::STRICT
208 ApiResult::setIndexedTagName( $fallbacks,
'fb' );
209 $info[
'fallbacks'] = $fallbacks;
212 if ( $includeVariants ) {
213 $language = $this->languageFactory->getLanguage( $languageCode );
214 $converter = $this->languageConverterFactory->getLanguageConverter( $language );
215 $variants = $converter->getVariants();
216 ApiResult::setIndexedTagName( $variants,
'var' );
217 $info[
'variants'] = $variants;
220 $fit = $result->addValue( $rootPath, $languageCode, $info );