MediaWiki
REL1_34
ParserOutputSearchDataExtractor.php
Go to the documentation of this file.
1
<?php
2
3
namespace
MediaWiki\Search
;
4
5
use
Category
;
6
use
ParserOutput
;
7
use
Title
;
8
29
class
ParserOutputSearchDataExtractor
{
30
37
public
function
getCategories
(
ParserOutput
$parserOutput ) {
38
$categories = [];
39
40
foreach
( $parserOutput->
getCategoryLinks
() as $key ) {
41
$categories[] =
Category::newFromName
( $key )->getTitle()->getText();
42
}
43
44
return
$categories;
45
}
46
53
public
function
getExternalLinks
(
ParserOutput
$parserOutput ) {
54
return
array_keys( $parserOutput->
getExternalLinks
() );
55
}
56
64
public
function
getOutgoingLinks
(
ParserOutput
$parserOutput ) {
65
$outgoingLinks = [];
66
67
foreach
( $parserOutput->
getLinks
() as $linkedNamespace => $namespaceLinks ) {
68
foreach
( array_keys( $namespaceLinks ) as $linkedDbKey ) {
69
$outgoingLinks[] =
70
Title::makeTitle( $linkedNamespace, $linkedDbKey )->getPrefixedDBkey();
71
}
72
}
73
74
return
$outgoingLinks;
75
}
76
83
public
function
getTemplates
(
ParserOutput
$parserOutput ) {
84
$templates = [];
85
86
foreach
( $parserOutput->
getTemplates
() as $tNS => $templatesInNS ) {
87
foreach
( array_keys( $templatesInNS ) as $tDbKey ) {
88
$templateTitle = Title::makeTitle( $tNS, $tDbKey );
89
$templates[] = $templateTitle->getPrefixedText();
90
}
91
}
92
93
return
$templates;
94
}
95
96
}
Category
Category objects are immutable, strictly speaking.
Definition
Category.php:29
Category\newFromName
static newFromName( $name)
Factory function.
Definition
Category.php:126
MediaWiki\Search\ParserOutputSearchDataExtractor
Extracts data from ParserOutput for indexing in the search engine.
Definition
ParserOutputSearchDataExtractor.php:29
MediaWiki\Search\ParserOutputSearchDataExtractor\getExternalLinks
getExternalLinks(ParserOutput $parserOutput)
Get a list of external links from ParserOutput, as an array of strings.
Definition
ParserOutputSearchDataExtractor.php:53
MediaWiki\Search\ParserOutputSearchDataExtractor\getCategories
getCategories(ParserOutput $parserOutput)
Get a list of categories, as an array with title text strings.
Definition
ParserOutputSearchDataExtractor.php:37
MediaWiki\Search\ParserOutputSearchDataExtractor\getOutgoingLinks
getOutgoingLinks(ParserOutput $parserOutput)
Get a list of outgoing wiki links (including interwiki links), as an array of prefixed title strings.
Definition
ParserOutputSearchDataExtractor.php:64
MediaWiki\Search\ParserOutputSearchDataExtractor\getTemplates
getTemplates(ParserOutput $parserOutput)
Get a list of templates used in the ParserOutput content, as prefixed title strings.
Definition
ParserOutputSearchDataExtractor.php:83
ParserOutput
Definition
ParserOutput.php:25
ParserOutput\getCategoryLinks
getCategoryLinks()
Definition
ParserOutput.php:529
ParserOutput\getExternalLinks
& getExternalLinks()
Definition
ParserOutput.php:573
ParserOutput\getLinks
& getLinks()
Definition
ParserOutput.php:553
ParserOutput\getTemplates
& getTemplates()
Definition
ParserOutput.php:557
Title
Represents a title within MediaWiki.
Definition
Title.php:42
MediaWiki\Search
Definition
ParserOutputSearchDataExtractor.php:3
includes
search
ParserOutputSearchDataExtractor.php
Generated on Fri Apr 5 2024 23:10:29 for MediaWiki by
1.9.8