Useful for search engines that allow users to customize search profiles.
Depends-On: Icd577c8ebc6e162befe30bde4fe276e633d2e434
Change-Id: I471cd090730d2a25cb70d622ec3bebbe9583118c
$searchEngine = MediaWikiServices::getInstance()->newSearchEngine();
$params = [];
foreach ( $configs as $paramName => $paramConfig ) {
- $profiles = $searchEngine->getProfiles( $paramConfig['profile-type'] );
+ $profiles = $searchEngine->getProfiles( $paramConfig['profile-type'],
+ $this->getContext()->getUser() );
if ( !$profiles ) {
continue;
}
* containing 'help-message' and 'profile-type' keys.
*/
abstract public function getSearchProfileParams();
+
+ /**
+ * @return IContextSource
+ */
+ abstract public function getContext();
}
* - default: set to true if this profile is the default
*
* @since 1.28
- * @param $profileType the type of profiles
+ * @param string $profileType the type of profiles
+ * @param User|null $user the user requesting the list of profiles
* @return array|null the list of profiles or null if none available
*/
- public function getProfiles( $profileType ) {
+ public function getProfiles( $profileType, User $user = null ) {
return null;
}
->method( 'getSearchTypes' )
->will( $this->returnValue( [ 'the one ring' ] ) );
+ $api = $this->createApi();
$engine = $this->replaceSearchEngine();
$engine->expects( $this->any() )
->method( 'getProfiles' )
->will( $this->returnValueMap( [
- [ SearchEngine::COMPLETION_PROFILE_TYPE, [
+ [ SearchEngine::COMPLETION_PROFILE_TYPE, $api->getUser(), [
[
'name' => 'normal',
'desc-message' => 'normal-message',
] ],
] ) );
- $api = $this->createApi();
$params = $api->getAllowedParams();
$this->assertArrayNotHasKey( 'offset', $params );