+ /**
+ * @since 1.27
+ * @see TitleFormatter::getPrefixedDBkey()
+ * @param LinkTarget $target
+ * @return string
+ */
+ public function getPrefixedDBkey( LinkTarget $target ) {
+ $key = '';
+ if ( $target->isExternal() ) {
+ $key .= $target->getInterwiki() . ':';
+ }
+ // Try to get a namespace name, but fallback
+ // to empty string if it doesn't exist
+ try {
+ $nsName = $this->getNamespaceName(
+ $target->getNamespace(),
+ $target->getText()
+ );
+ } catch ( InvalidArgumentException $e ) {
+ $nsName = '';
+ }
+
+ if ( $target->getNamespace() !== 0 ) {
+ $key .= $nsName . ':';
+ }
+
+ $key .= $target->getText();
+
+ return strtr( $key, ' ', '_' );
+ }
+