MediaWiki master
LinkRendererFactory.php
Go to the documentation of this file.
1<?php
7namespace MediaWiki\Linker;
8
19
25
27
31 public function __construct(
32 private TitleFormatter $titleFormatter,
33 private LinkCache $linkCache,
34 private SpecialPageFactory $specialPageFactory,
35 private HookContainer $hookContainer,
36 private TempUserConfig $tempUserConfig,
37 private TempUserDetailsLookup $tempUserDetailsLookup,
38 private UserIdentityLookup $userIdentityLookup,
39 private UserNameUtils $userNameUtils,
40 private UrlUtils $urlUtils,
41 private ServiceOptions $options,
42 ) {
43 }
44
53 public function create( array $options = [ 'renderForComment' => false ] ) {
54 return new LinkRenderer(
55 $this->titleFormatter, $this->linkCache, $this->specialPageFactory,
56 $this->hookContainer, $this->tempUserConfig,
57 $this->tempUserDetailsLookup, $this->userIdentityLookup,
58 $this->userNameUtils,
59 $this->urlUtils,
60 $this->options,
61 $options['renderForComment'] ?? false,
62 );
63 }
64
69 public function createFromLegacyOptions( array $options ) {
70 $linkRenderer = $this->create();
71
72 if ( in_array( 'forcearticlepath', $options, true ) ) {
73 $linkRenderer->setForceArticlePath( true );
74 }
75
76 if ( in_array( 'http', $options, true ) ) {
77 $linkRenderer->setExpandURLs( PROTO_HTTP );
78 } elseif ( in_array( 'https', $options, true ) ) {
79 $linkRenderer->setExpandURLs( PROTO_HTTPS );
80 }
81
82 return $linkRenderer;
83 }
84}
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.
__construct(private TitleFormatter $titleFormatter, private LinkCache $linkCache, private SpecialPageFactory $specialPageFactory, private HookContainer $hookContainer, private TempUserConfig $tempUserConfig, private TempUserDetailsLookup $tempUserDetailsLookup, private UserIdentityLookup $userIdentityLookup, private UserNameUtils $userNameUtils, private UrlUtils $urlUtils, private ServiceOptions $options,)
create(array $options=[ 'renderForComment'=> false])
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.
A service to expand, parse, and otherwise manipulate URLs.
Definition UrlUtils.php:16
Interface for temporary user creation config and name matching.
Service for looking up UserIdentity.