MediaWiki REL1_31
LinkRendererFactory.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\Linker;
22
23use LinkCache;
25use User;
26
32
37
41 private $linkCache;
42
48 $this->titleFormatter = $titleFormatter;
49 $this->linkCache = $linkCache;
50 }
51
55 public function create() {
56 return new LinkRenderer( $this->titleFormatter, $this->linkCache );
57 }
58
63 public function createForUser( User $user ) {
64 $linkRenderer = $this->create();
65 $linkRenderer->setStubThreshold( $user->getStubThreshold() );
66
67 return $linkRenderer;
68 }
69
74 public function createFromLegacyOptions( array $options ) {
75 $linkRenderer = $this->create();
76
77 if ( in_array( 'forcearticlepath', $options, true ) ) {
78 $linkRenderer->setForceArticlePath( true );
79 }
80
81 if ( in_array( 'http', $options, true ) ) {
82 $linkRenderer->setExpandURLs( PROTO_HTTP );
83 } elseif ( in_array( 'https', $options, true ) ) {
84 $linkRenderer->setExpandURLs( PROTO_HTTPS );
85 }
86
87 if ( isset( $options['stubThreshold'] ) ) {
88 $linkRenderer->setStubThreshold(
89 $options['stubThreshold']
90 );
91 }
92
93 return $linkRenderer;
94 }
95}
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:53
getStubThreshold()
Get the user preferred stub threshold.
Definition User.php:3519
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:2001
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:2056
const PROTO_HTTPS
Definition Defines.php:230
const PROTO_HTTP
Definition Defines.php:229
A title formatter service for MediaWiki.