MediaWiki REL1_35
LinkRendererFactory.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\Linker;
22
23use LinkCache;
28use User;
29
35
40
44 private $linkCache;
45
49 private $nsInfo;
50
55
60
69 public function __construct(
75 ) {
76 $this->titleFormatter = $titleFormatter;
77 $this->linkCache = $linkCache;
78 $this->nsInfo = $nsInfo;
79 $this->specialPageFactory = $specialPageFactory;
80 $this->hookContainer = $hookContainer;
81 }
82
86 public function create() {
87 return new LinkRenderer(
88 $this->titleFormatter, $this->linkCache, $this->nsInfo, $this->specialPageFactory,
89 $this->hookContainer
90 );
91 }
92
97 public function createForUser( User $user ) {
98 $linkRenderer = $this->create();
99 $linkRenderer->setStubThreshold( $user->getStubThreshold() );
100
101 return $linkRenderer;
102 }
103
108 public function createFromLegacyOptions( array $options ) {
109 $linkRenderer = $this->create();
110
111 if ( in_array( 'forcearticlepath', $options, true ) ) {
112 $linkRenderer->setForceArticlePath( true );
113 }
114
115 if ( in_array( 'http', $options, true ) ) {
116 $linkRenderer->setExpandURLs( PROTO_HTTP );
117 } elseif ( in_array( 'https', $options, true ) ) {
118 $linkRenderer->setExpandURLs( PROTO_HTTPS );
119 }
120
121 if ( isset( $options['stubThreshold'] ) ) {
122 $linkRenderer->setStubThreshold(
123 $options['stubThreshold']
124 );
125 }
126
127 return $linkRenderer;
128 }
129}
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, NamespaceInfo $nsInfo, SpecialPageFactory $specialPageFactory, HookContainer $hookContainer)
Class that generates HTML links for pages.
Factory for handling the special page list and generating SpecialPage objects.
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition User.php:60
getStubThreshold()
Get the user preferred stub threshold.
Definition User.php:2908
const PROTO_HTTPS
Definition Defines.php:210
const PROTO_HTTP
Definition Defines.php:209
A title formatter service for MediaWiki.