MediaWiki master
LinkRendererFactory.php
Go to the documentation of this file.
1<?php
7namespace MediaWiki\Linker;
8
18
24
28 private $titleFormatter;
29
33 private $linkCache;
34
38 private $hookContainer;
39
43 private $specialPageFactory;
44
45 private TempUserConfig $tempUserConfig;
46 private TempUserDetailsLookup $tempUserDetailsLookup;
47 private UserIdentityLookup $userIdentityLookup;
48 private UserNameUtils $userNameUtils;
49
53 public function __construct(
54 TitleFormatter $titleFormatter,
55 LinkCache $linkCache,
56 SpecialPageFactory $specialPageFactory,
57 HookContainer $hookContainer,
58 TempUserConfig $tempUserConfig,
59 TempUserDetailsLookup $tempUserDetailsLookup,
60 UserIdentityLookup $userIdentityLookup,
61 UserNameUtils $userNameUtils
62 ) {
63 $this->titleFormatter = $titleFormatter;
64 $this->linkCache = $linkCache;
65 $this->specialPageFactory = $specialPageFactory;
66 $this->hookContainer = $hookContainer;
67 $this->tempUserConfig = $tempUserConfig;
68 $this->tempUserDetailsLookup = $tempUserDetailsLookup;
69 $this->userIdentityLookup = $userIdentityLookup;
70 $this->userNameUtils = $userNameUtils;
71 }
72
81 public function create( array $options = [ 'renderForComment' => false ] ) {
82 return new LinkRenderer(
83 $this->titleFormatter, $this->linkCache, $this->specialPageFactory,
84 $this->hookContainer, $this->tempUserConfig,
85 $this->tempUserDetailsLookup, $this->userIdentityLookup,
86 $this->userNameUtils,
88 );
89 }
90
95 public function createFromLegacyOptions( array $options ) {
96 $linkRenderer = $this->create();
97
98 if ( in_array( 'forcearticlepath', $options, true ) ) {
99 $linkRenderer->setForceArticlePath( true );
100 }
101
102 if ( in_array( 'http', $options, true ) ) {
103 $linkRenderer->setExpandURLs( PROTO_HTTP );
104 } elseif ( in_array( 'https', $options, true ) ) {
105 $linkRenderer->setExpandURLs( PROTO_HTTPS );
106 }
107
108 return $linkRenderer;
109 }
110}
const PROTO_HTTPS
Definition Defines.php:218
const PROTO_HTTP
Definition Defines.php:217
A class for passing options to services.
Factory to create LinkRender objects.
create(array $options=[ 'renderForComment'=> false])
__construct(TitleFormatter $titleFormatter, LinkCache $linkCache, SpecialPageFactory $specialPageFactory, HookContainer $hookContainer, TempUserConfig $tempUserConfig, TempUserDetailsLookup $tempUserDetailsLookup, UserIdentityLookup $userIdentityLookup, UserNameUtils $userNameUtils)
Class that generates HTML for internal links.
Page existence and metadata cache.
Definition LinkCache.php:54
Factory for handling the special page list and generating SpecialPage objects.
A title formatter service for MediaWiki.
Caching lookup service for metadata related to temporary accounts, such as expiration.
UserNameUtils service.
Interface for temporary user creation config and name matching.
Service for looking up UserIdentity.