MediaWiki master
LinkTarget.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\Linker;
22
23use Wikimedia\Parsoid\Core\LinkTarget as ParsoidLinkTarget;
24
32interface LinkTarget extends ParsoidLinkTarget {
33
40 public function getNamespace(): int;
41
49 public function inNamespace( int $ns ): bool;
50
57 public function getFragment(): string;
58
65 public function hasFragment(): bool;
66
77 public function getDBkey(): string;
78
93 public function getText(): string;
94
105 public function createFragmentTarget( string $fragment );
106
113 public function isExternal(): bool;
114
121 public function getInterwiki(): string;
122
133 public function isSameLinkAs( ParsoidLinkTarget $other ): bool;
134
141 public function __toString(): string;
142
143}
Represents the target of a wiki link.
inNamespace(int $ns)
Convenience function to check if the target is in a given namespace.
getInterwiki()
The interwiki component of this LinkTarget.
hasFragment()
Whether the link target has a fragment.
__toString()
Return an informative human-readable representation of the link target, for use in logging and debugg...
getFragment()
Get the link fragment in text form (i.e.
getNamespace()
Get the namespace index.
getDBkey()
Get the main part of the link target, in canonical database form.
isSameLinkAs(ParsoidLinkTarget $other)
Check whether the given LinkTarget refers to the same target as this LinkTarget.
isExternal()
Whether this LinkTarget has an interwiki component.
getText()
Get the main part of the link target, in text form.
createFragmentTarget(string $fragment)
Create a new LinkTarget with a different fragment on the same page.