MediaWiki REL1_34
LinkRendererFactory.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\Linker;
22
23use LinkCache;
26use User;
27
33
38
42 private $linkCache;
43
47 private $nsInfo;
48
54 public function __construct(
56 ) {
57 $this->titleFormatter = $titleFormatter;
58 $this->linkCache = $linkCache;
59 $this->nsInfo = $nsInfo;
60 }
61
65 public function create() {
66 return new LinkRenderer( $this->titleFormatter, $this->linkCache, $this->nsInfo );
67 }
68
73 public function createForUser( User $user ) {
74 $linkRenderer = $this->create();
75 $linkRenderer->setStubThreshold( $user->getStubThreshold() );
76
77 return $linkRenderer;
78 }
79
84 public function createFromLegacyOptions( array $options ) {
85 $linkRenderer = $this->create();
86
87 if ( in_array( 'forcearticlepath', $options, true ) ) {
88 $linkRenderer->setForceArticlePath( true );
89 }
90
91 if ( in_array( 'http', $options, true ) ) {
92 $linkRenderer->setExpandURLs( PROTO_HTTP );
93 } elseif ( in_array( 'https', $options, true ) ) {
94 $linkRenderer->setExpandURLs( PROTO_HTTPS );
95 }
96
97 if ( isset( $options['stubThreshold'] ) ) {
98 $linkRenderer->setStubThreshold(
99 $options['stubThreshold']
100 );
101 }
102
103 return $linkRenderer;
104 }
105}
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)
Class that generates HTML links for pages.
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:51
getStubThreshold()
Get the user preferred stub threshold.
Definition User.php:3387
const PROTO_HTTPS
Definition Defines.php:209
const PROTO_HTTP
Definition Defines.php:208
A title formatter service for MediaWiki.