MediaWiki  master
LinkRendererFactory.php
Go to the documentation of this file.
1 <?php
21 namespace MediaWiki\Linker;
22 
23 use LinkCache;
26 use NamespaceInfo;
27 use TitleFormatter;
28 use User;
29 
35 
39  private $titleFormatter;
40 
44  private $linkCache;
45 
49  private $nsInfo;
50 
54  private $hookContainer;
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 }
LinkCache
Cache for article titles (prefixed DB keys) and ids linked from one source.
Definition: LinkCache.php:34
MediaWiki\Linker\LinkRenderer
Class that generates HTML links for pages.
Definition: LinkRenderer.php:41
MediaWiki\SpecialPage\SpecialPageFactory
Factory for handling the special page list and generating SpecialPage objects.
Definition: SpecialPageFactory.php:65
User\getStubThreshold
getStubThreshold()
Get the user preferred stub threshold.
Definition: User.php:2845
MediaWiki\Linker\LinkRendererFactory\createFromLegacyOptions
createFromLegacyOptions(array $options)
Definition: LinkRendererFactory.php:108
MediaWiki\Linker\LinkRendererFactory
Factory to create LinkRender objects.
Definition: LinkRendererFactory.php:34
MediaWiki\Linker\LinkRendererFactory\createForUser
createForUser(User $user)
Definition: LinkRendererFactory.php:97
MediaWiki\Linker\LinkRendererFactory\$specialPageFactory
SpecialPageFactory $specialPageFactory
Definition: LinkRendererFactory.php:59
MediaWiki\Linker
MediaWiki\Linker\LinkRendererFactory\$nsInfo
NamespaceInfo $nsInfo
Definition: LinkRendererFactory.php:49
PROTO_HTTPS
const PROTO_HTTPS
Definition: Defines.php:209
PROTO_HTTP
const PROTO_HTTP
Definition: Defines.php:208
MediaWiki\Linker\LinkRendererFactory\$hookContainer
HookContainer $hookContainer
Definition: LinkRendererFactory.php:54
MediaWiki\Linker\LinkRendererFactory\$titleFormatter
TitleFormatter $titleFormatter
Definition: LinkRendererFactory.php:39
TitleFormatter
A title formatter service for MediaWiki.
Definition: TitleFormatter.php:34
MediaWiki\HookContainer\HookContainer
HookContainer class.
Definition: HookContainer.php:44
NamespaceInfo
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
Definition: NamespaceInfo.php:35
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:56
MediaWiki\Linker\LinkRendererFactory\create
create()
Definition: LinkRendererFactory.php:86
MediaWiki\Linker\LinkRendererFactory\__construct
__construct(TitleFormatter $titleFormatter, LinkCache $linkCache, NamespaceInfo $nsInfo, SpecialPageFactory $specialPageFactory, HookContainer $hookContainer)
Definition: LinkRendererFactory.php:69
MediaWiki\Linker\LinkRendererFactory\$linkCache
LinkCache $linkCache
Definition: LinkRendererFactory.php:44