MediaWiki master
TemplateLinksTable.php
Go to the documentation of this file.
1<?php
2
4
5use LogicException;
8
15 public const VIRTUAL_DOMAIN = 'virtual-templatelinks';
16
17 public function setParserOutput( ParserOutput $parserOutput ) {
18 // Convert the format of the template links
19 $this->newLinks = [];
20 foreach (
21 $parserOutput->getLinkList( ParserOutputLinkTypes::TEMPLATE )
22 as [ 'link' => $link, 'pageid' => $pageid ]
23 ) {
24 $this->newLinks[$link->getNamespace()][$link->getDBkey()] = $pageid;
25 }
26 }
27
29 protected function getTableName() {
30 return 'templatelinks';
31 }
32
34 protected function getFromField() {
35 return 'tl_from';
36 }
37
39 protected function getNamespaceField() {
40 // @phan-suppress-previous-line PhanPluginNeverReturnMethod
41 throw new LogicException( 'not supported' );
42 }
43
45 protected function getTitleField() {
46 // @phan-suppress-previous-line PhanPluginNeverReturnMethod
47 throw new LogicException( 'not supported' );
48 }
49
51 protected function getFromNamespaceField() {
52 return 'tl_from_namespace';
53 }
54
56 protected function getTargetIdField() {
57 return 'tl_target_id';
58 }
59
61 protected function virtualDomain() {
63 }
64}
Shared code for pagelinks, templatelinks and existencelinks.
getNamespaceField()
Get the namespace field name.string
virtualDomain()
What virtual domain should be used to read/write from the table.string|bool
setParserOutput(ParserOutput $parserOutput)
Subclasses should implement this to extract the data they need from the ParserOutput.
getTitleField()
Get the title (DB key) field name.string
getFromField()
Get the name of the field which links to page_id.string
getTargetIdField()
Get the link target id (DB key) field name.string
ParserOutput is a rendering of a Content object or a message.
getLinkList(string|ParserOutputLinkTypes $linkType, ?int $onlyNamespace=null)
Get a list of links of the given type.