Wikibase
MediaWiki Wikibase extension
Wikibase.searchindex.php File Reference

Variables

if(!defined( 'MEDIAWIKI')) global $wgHooks
 Example showing how the search index behavior for Wikibase entities can be controlled using the WikibaseTextForSearchIndex hook. More...
 
 $wgHooks ['WikibaseTextForSearchIndex'][]
 

Variable Documentation

◆ $wgHooks [1/2]

if (!defined('MEDIAWIKI')) global $wgHooks

Example showing how the search index behavior for Wikibase entities can be controlled using the WikibaseTextForSearchIndex hook.

If this config file is included, the search index will include all string and text values present in the main snak of any statement associated with an item.

Author
Daniel Kinzler

◆ $wgHooks [2/2]

$wgHooks[ 'WikibaseTextForSearchIndex'][]
Initial value:
= function( EntityContent $entityContent, &$text ) {
if ( !( $entityContent instanceof ItemContent ) ) {
return;
}
$statements = $entityContent->getItem()->getStatements();
foreach ( $statements as $statement ) {
$snak = $statement->getMainSnak();
if ( !( $snak instanceof PropertyValueSnak ) ) {
continue;
}
$value = $snak->getDataValue();
if ( $value instanceof StringValue ) {
$text .= $value->getValue() . "\n";
} elseif ( $value instanceof MonolingualTextValue ) {
$text .= $value->getText() . "\n";
}
}
}
Abstract content object for articles representing Wikibase entities.
Definition: EntityContent.php:50
Content object for articles representing Wikibase items.
Definition: ItemContent.php:24