Merge "resourceloader: Add explicit tests for isValidModuleName()"
[lhc/web/wiklou.git] / includes / interwiki / InterwikiLookupAdapter.php
index 60d6f43..4f46580 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+
 namespace MediaWiki\Interwiki;
 
 /**
@@ -24,7 +25,7 @@ namespace MediaWiki\Interwiki;
  * @since 1.29
  * @ingroup InterwikiLookup
  *
- * @license GNU GPL v2+
+ * @license GPL-2.0-or-later
  */
 
 use Interwiki;
@@ -60,7 +61,6 @@ class InterwikiLookupAdapter implements InterwikiLookup {
         * @return bool Whether it exists
         */
        public function isValidInterwiki( $prefix ) {
-
                return array_key_exists( $prefix, $this->getInterwikiMap() );
        }
 
@@ -87,16 +87,20 @@ class InterwikiLookupAdapter implements InterwikiLookup {
         * See InterwikiLookup::getAllPrefixes
         *
         * @param string|null $local If set, limits output to local/non-local interwikis
-        * @return string[] List of prefixes
+        * @return array[] interwiki rows
         */
        public function getAllPrefixes( $local = null ) {
-               if ( $local === null ) {
-                       return array_keys( $this->getInterwikiMap() );
-               }
                $res = [];
                foreach ( $this->getInterwikiMap() as $interwikiId => $interwiki ) {
-                       if ( $interwiki->isLocal() === $local ) {
-                               $res[] = $interwikiId;
+                       if ( $local === null || $interwiki->isLocal() === $local ) {
+                               $res[] = [
+                                       'iw_prefix' => $interwikiId,
+                                       'iw_url' => $interwiki->getURL(),
+                                       'iw_api' => $interwiki->getAPI(),
+                                       'iw_wikiid' => $interwiki->getWikiID(),
+                                       'iw_local' => $interwiki->isLocal(),
+                                       'iw_trans' => $interwiki->isTranscludable(),
+                               ];
                        }
                }
                return $res;