MediaWiki REL1_30
LinkRendererFactory.php
Go to the documentation of this file.
1<?php
22namespace MediaWiki\Linker;
23
24use LinkCache;
26use User;
27
33
38
42 private $linkCache;
43
49 $this->titleFormatter = $titleFormatter;
50 $this->linkCache = $linkCache;
51 }
52
56 public function create() {
57 return new LinkRenderer( $this->titleFormatter, $this->linkCache );
58 }
59
64 public function createForUser( User $user ) {
65 $linkRenderer = $this->create();
66 $linkRenderer->setStubThreshold( $user->getStubThreshold() );
67
68 return $linkRenderer;
69 }
70
75 public function createFromLegacyOptions( array $options ) {
76 $linkRenderer = $this->create();
77
78 if ( in_array( 'forcearticlepath', $options, true ) ) {
79 $linkRenderer->setForceArticlePath( true );
80 }
81
82 if ( in_array( 'http', $options, true ) ) {
83 $linkRenderer->setExpandURLs( PROTO_HTTP );
84 } elseif ( in_array( 'https', $options, true ) ) {
85 $linkRenderer->setExpandURLs( PROTO_HTTPS );
86 }
87
88 if ( isset( $options['stubThreshold'] ) ) {
89 $linkRenderer->setStubThreshold(
90 $options['stubThreshold']
91 );
92 }
93
94 return $linkRenderer;
95 }
96}
Cache for article titles (prefixed DB keys) and ids linked from one source.
Definition LinkCache.php:34
Factory to create LinkRender objects.
__construct(TitleFormatter $titleFormatter, LinkCache $linkCache)
Class that generates HTML links for pages.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition User.php:51
getStubThreshold()
Get the user preferred stub threshold.
Definition User.php:3243
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
Definition hooks.txt:1971
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after in associative array form before processing starts Return false to skip default processing and return $ret $linkRenderer
Definition hooks.txt:2026
const PROTO_HTTPS
Definition Defines.php:221
const PROTO_HTTP
Definition Defines.php:220
A title formatter service for MediaWiki.