/**
* Return the CSS colour of a known link
*
+ * @deprecated since 1.28, use LinkRenderer::getLinkClasses() instead
+ *
* @since 1.16.3
* @param LinkTarget $t
* @param int $threshold User defined threshold
* @return string CSS class
*/
public static function getLinkColour( LinkTarget $t, $threshold ) {
- $linkCache = MediaWikiServices::getInstance()->getLinkCache();
- // Make sure the target is in the cache
- $id = $linkCache->addLinkObj( $t );
- if ( $id == 0 ) {
- // Doesn't exist
- return '';
- }
-
- if ( $linkCache->getGoodLinkFieldObj( $t, 'redirect' ) ) {
- # Page is a redirect
- return 'mw-redirect';
- } elseif ( $threshold > 0 && MWNamespace::isContent( $t->getNamespace() )
- && $linkCache->getGoodLinkFieldObj( $t, 'length' ) < $threshold
- ) {
- # Page is a stub
- return 'stub';
+ wfDeprecated( __METHOD__, '1.28' );
+ $services = MediaWikiServices::getInstance();
+ $linkRenderer = $services->getLinkRenderer();
+ if ( $threshold !== $linkRenderer->getStubThreshold() ) {
+ // Need to create a new instance with the right stub threshold...
+ $linkRenderer = $services->getLinkRendererFactory()->create();
+ $linkRenderer->setStubThreshold( $threshold );
}
- return '';
+ return $linkRenderer->getLinkClasses( $t );
}
/**