| 1 | <?php |
| 2 | /** |
| 3 | * Prefix search of user names. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License along |
| 16 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 18 | * http://www.gnu.org/copyleft/gpl.html |
| 19 | * |
| 20 | * @file |
| 21 | */ |
| 22 | |
| 23 | use MediaWiki\MediaWikiServices; |
| 24 | use MediaWiki\User\User; |
| 25 | |
| 26 | // phpcs:disable MediaWiki.Files.ClassMatchesFilename.NotMatch |
| 27 | /** |
| 28 | * Handles searching prefixes of user names |
| 29 | * |
| 30 | * @note There are two classes called UserNamePrefixSearch. You should use the first one, in |
| 31 | * namespace MediaWiki\User, which is a service. \UserNamePrefixSearch is a deprecated static wrapper |
| 32 | * that forwards to the global service. |
| 33 | * |
| 34 | * @deprecated since 1.36, use the MediaWiki\User\UserNamePrefixSearch service; hard deprecated |
| 35 | * since 1.41 |
| 36 | * |
| 37 | * @since 1.27 |
| 38 | */ |
| 39 | class UserNamePrefixSearch { |
| 40 | |
| 41 | /** |
| 42 | * Do a prefix search of user names and return a list of matching user names. |
| 43 | * |
| 44 | * @deprecated since 1.36, use the MediaWiki\User\UserNamePrefixSearch service instead; hard |
| 45 | * deprecated since 1.41 |
| 46 | * |
| 47 | * @param string|User $audience The string 'public' or a user object to show the search for |
| 48 | * @param string $search |
| 49 | * @param int $limit |
| 50 | * @param int $offset How many results to offset from the beginning |
| 51 | * @return string[] |
| 52 | */ |
| 53 | public static function search( $audience, $search, $limit, $offset = 0 ) { |
| 54 | wfDeprecated( __METHOD__, '1.36' ); |
| 55 | return MediaWikiServices::getInstance() |
| 56 | ->getUserNamePrefixSearch() |
| 57 | ->search( $audience, (string)$search, (int)$limit, (int)$offset ); |
| 58 | } |
| 59 | } |