jenkins-bot has submitted this change and it was merged.
Change subject: Add LinkTarget interface
......................................................................
Add LinkTarget interface
To be used by things that do not care if they are
passed a Title or TitleValue so long as it has a
dbkey, namespace, possible fragment and text
Example uses include:
LinkBatch::addObj
MediaWikiPageLinkRenderer methods
MediaWikiTitleCodec methods
PageLinkRenderer methods
TitleFormatter methods
Change-Id: I2aa1a82129bb01155924a8e6a403c7a47391432f
---
M autoload.php
A includes/LinkTarget.php
M includes/Title.php
M includes/title/TitleValue.php
4 files changed, 44 insertions(+), 2 deletions(-)
Approvals:
WMDE-Fisch: Looks good to me, but someone else must approve
Daniel Kinzler: Looks good to me, approved
jenkins-bot: Verified
diff --git a/autoload.php b/autoload.php
index 24a4d72..11dc7e1 100644
--- a/autoload.php
+++ b/autoload.php
@@ -560,6 +560,7 @@
'IPSet' => __DIR__ . '/includes/compat/IPSetCompat.php',
'IPTC' => __DIR__ . '/includes/media/IPTC.php',
'IRCColourfulRCFeedFormatter' => __DIR__ .
'/includes/rcfeed/IRCColourfulRCFeedFormatter.php',
+ 'LinkTarget' => __DIR__ . '/includes/LinkTarget.php',
'IcuCollation' => __DIR__ . '/includes/Collation.php',
'IdentityCollation' => __DIR__ . '/includes/Collation.php',
'ImageBuilder' => __DIR__ . '/maintenance/rebuildImages.php',
diff --git a/includes/LinkTarget.php b/includes/LinkTarget.php
new file mode 100644
index 0000000..1ce5f32
--- /dev/null
+++ b/includes/LinkTarget.php
@@ -0,0 +1,41 @@
+<?php
+
+/**
+ * @author Addshore
+ *
+ * @since 1.27
+ */
+interface LinkTarget {
+
+ /**
+ * Get the namespace index
+ *
+ * @return int Namespace index
+ */
+ public function getNamespace();
+
+ /**
+ * Get the link fragment (i.e.\ the bit after the #) in text form
+ *
+ * @return string link fragment
+ */
+ public function getFragment();
+
+ /**
+ * Get the main part with underscores
+ *
+ * @return string Main part of the link, with underscores (for use in
hrf attributes)
+ */
+ public function getDBkey();
+
+ /**
+ * Returns the link in text form,
+ * without namespace prefix or fragment.
+ *
+ * This is computed from the DB key by replacing any underscores with
spaces.
+ *
+ * @return string
+ */
+ public function getText();
+
+}
diff --git a/includes/Title.php b/includes/Title.php
index e549037..f2a33e2 100644
--- a/includes/Title.php
+++ b/includes/Title.php
@@ -30,7 +30,7 @@
* @note Consider using a TitleValue object instead. TitleValue is more
lightweight
* and does not rely on global state or the database.
*/
-class Title {
+class Title implements LinkTarget {
/** @var HashBagOStuff */
static private $titleCache = null;
diff --git a/includes/title/TitleValue.php b/includes/title/TitleValue.php
index a0f3b6f..c8ebc2a 100644
--- a/includes/title/TitleValue.php
+++ b/includes/title/TitleValue.php
@@ -35,7 +35,7 @@
* @see https://www.mediawiki.org/wiki/Requests_for_comment/TitleValue
* @since 1.23
*/
-class TitleValue {
+class TitleValue implements LinkTarget {
/**
* @var int
*/
--
To view, visit https://gerrit.wikimedia.org/r/266577
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I2aa1a82129bb01155924a8e6a403c7a47391432f
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Bartosz DziewoĆski <[email protected]>
Gerrit-Reviewer: BryanDavis <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: DannyH (WMF) <[email protected]>
Gerrit-Reviewer: Fhocutt <[email protected]>
Gerrit-Reviewer: Florianschmidtwelzow <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: Kaldari <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Niharika29 <[email protected]>
Gerrit-Reviewer: Tim Starling <[email protected]>
Gerrit-Reviewer: WMDE-Fisch <[email protected]>
Gerrit-Reviewer: WMDE-leszek <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits