MediaWiki master
SearchSuggestion Class Reference

A search suggestion. More...

Public Member Functions

 __construct ( $score, $text=null, ?Title $suggestedTitle=null, $suggestedTitleID=null)
 
 getScore ()
 Suggestion score.
 
 getSuggestedTitle ()
 Title object in the case this suggestion is based on a title.
 
 getSuggestedTitleID ()
 Title ID in the case this suggestion is based on a title.
 
 getText ()
 The suggestion text.
 
 getURL ()
 Suggestion URL, can be the link to the Title or maybe in the future a link to the search results for this search suggestion.
 
 setScore ( $score)
 Set the suggestion score.
 
 setSuggestedTitle (?Title $title=null)
 
 setSuggestedTitleID ( $suggestedTitleID=null)
 
 setText ( $text, $setTitle=true)
 Set the suggestion text.
 
 setURL ( $url)
 Set the suggestion URL.
 

Static Public Member Functions

static fromText ( $score, $text)
 Create suggestion from text Will also create a title if text if not empty.
 
static fromTitle ( $score, Title $title)
 Create suggestion from Title.
 

Detailed Description

A search suggestion.

Definition at line 28 of file SearchSuggestion.php.

Constructor & Destructor Documentation

◆ __construct()

SearchSuggestion::__construct ( $score,
$text = null,
?Title $suggestedTitle = null,
$suggestedTitleID = null )
Parameters
float$scorethe suggestion score
string | null$textthe suggestion text
Title | null$suggestedTitle
int | null$suggestedTitleID

Definition at line 62 of file SearchSuggestion.php.

References setSuggestedTitle().

Member Function Documentation

◆ fromText()

static SearchSuggestion::fromText ( $score,
$text )
static

Create suggestion from text Will also create a title if text if not empty.

Parameters
float$scoreSuggestions score
string$text
Returns
SearchSuggestion

Definition at line 178 of file SearchSuggestion.php.

◆ fromTitle()

static SearchSuggestion::fromTitle ( $score,
Title $title )
static

Create suggestion from Title.

Parameters
float$scoreSuggestions score
Title$title
Returns
SearchSuggestion

Definition at line 167 of file SearchSuggestion.php.

References MediaWiki\Title\Title\getArticleID(), and MediaWiki\Title\Title\getPrefixedText().

◆ getScore()

SearchSuggestion::getScore ( )

Suggestion score.

Returns
float Suggestion score

Definition at line 132 of file SearchSuggestion.php.

Referenced by SearchSuggestionSet\append(), and SearchSuggestionSet\prepend().

◆ getSuggestedTitle()

SearchSuggestion::getSuggestedTitle ( )

Title object in the case this suggestion is based on a title.

May return null if the suggestion is not a Title.

Returns
Title|null

Definition at line 97 of file SearchSuggestion.php.

Referenced by SearchEngine\extractTitles(), and SearchEngine\processCompletionResults().

◆ getSuggestedTitleID()

SearchSuggestion::getSuggestedTitleID ( )

Title ID in the case this suggestion is based on a title.

May return null if the suggestion is not a Title.

Returns
int|null

Definition at line 117 of file SearchSuggestion.php.

Referenced by SearchSuggestionSet\append(), and SearchSuggestionSet\prepend().

◆ getText()

SearchSuggestion::getText ( )

The suggestion text.

Returns
string

Definition at line 76 of file SearchSuggestion.php.

◆ getURL()

SearchSuggestion::getURL ( )

Suggestion URL, can be the link to the Title or maybe in the future a link to the search results for this search suggestion.

Returns
string Suggestion URL

Definition at line 149 of file SearchSuggestion.php.

References $url.

◆ setScore()

SearchSuggestion::setScore ( $score)

Set the suggestion score.

Parameters
float$score

Definition at line 140 of file SearchSuggestion.php.

Referenced by SearchSuggestionSet\append(), and SearchSuggestionSet\prepend().

◆ setSuggestedTitle()

SearchSuggestion::setSuggestedTitle ( ?Title $title = null)
Parameters
Title | null$title

Definition at line 104 of file SearchSuggestion.php.

References PROTO_CURRENT.

Referenced by __construct(), and setText().

◆ setSuggestedTitleID()

SearchSuggestion::setSuggestedTitleID ( $suggestedTitleID = null)
Parameters
int | null$suggestedTitleID

Definition at line 124 of file SearchSuggestion.php.

◆ setText()

SearchSuggestion::setText ( $text,
$setTitle = true )

Set the suggestion text.

Parameters
string$text
bool$setTitleShould we also update the title?

Definition at line 85 of file SearchSuggestion.php.

References setSuggestedTitle().

◆ setURL()

SearchSuggestion::setURL ( $url)

Set the suggestion URL.

Parameters
string$url

Definition at line 157 of file SearchSuggestion.php.

References $url.


The documentation for this class was generated from the following file: