MediaWiki  master
LinkRendererFactory.php
Go to the documentation of this file.
1 <?php
21 namespace MediaWiki\Linker;
22 
23 use LinkCache;
28 use TitleFormatter;
29 
35 
39  private $titleFormatter;
40 
44  private $linkCache;
45 
49  private $hookContainer;
50 
55 
63  public function __construct(
68  ) {
69  $this->titleFormatter = $titleFormatter;
70  $this->linkCache = $linkCache;
71  $this->specialPageFactory = $specialPageFactory;
72  $this->hookContainer = $hookContainer;
73  }
74 
83  public function create( array $options = [ 'renderForComment' => false ] ) {
84  return new LinkRenderer(
85  $this->titleFormatter, $this->linkCache, $this->specialPageFactory,
86  $this->hookContainer,
88  );
89  }
90 
97  public function createForUser( UserIdentity $user ) {
98  wfDeprecated( __METHOD__, '1.37' );
99  return $this->create();
100  }
101 
106  public function createFromLegacyOptions( array $options ) {
107  $linkRenderer = $this->create();
108 
109  if ( in_array( 'forcearticlepath', $options, true ) ) {
110  $linkRenderer->setForceArticlePath( true );
111  }
112 
113  if ( in_array( 'http', $options, true ) ) {
114  $linkRenderer->setExpandURLs( PROTO_HTTP );
115  } elseif ( in_array( 'https', $options, true ) ) {
116  $linkRenderer->setExpandURLs( PROTO_HTTPS );
117  }
118 
119  return $linkRenderer;
120  }
121 }
LinkCache
Cache for article titles (prefixed DB keys) and ids linked from one source.
Definition: LinkCache.php:41
PROTO_HTTPS
const PROTO_HTTPS
Definition: Defines.php:193
MediaWiki\Linker\LinkRenderer
Class that generates HTML anchor link elements for pages.
Definition: LinkRenderer.php:43
MediaWiki\SpecialPage\SpecialPageFactory
Factory for handling the special page list and generating SpecialPage objects.
Definition: SpecialPageFactory.php:63
MediaWiki\Linker\LinkRendererFactory\createFromLegacyOptions
createFromLegacyOptions(array $options)
Definition: LinkRendererFactory.php:106
MediaWiki\Linker\LinkRendererFactory
Factory to create LinkRender objects.
Definition: LinkRendererFactory.php:34
MediaWiki\User\UserIdentity
Interface for objects representing user identity.
Definition: UserIdentity.php:39
MediaWiki\Linker\LinkRendererFactory\create
create(array $options=[ 'renderForComment'=> false])
Definition: LinkRendererFactory.php:83
MediaWiki\Linker\LinkRenderer\CONSTRUCTOR_OPTIONS
const CONSTRUCTOR_OPTIONS
Definition: LinkRenderer.php:45
MediaWiki\Linker\LinkRendererFactory\$specialPageFactory
SpecialPageFactory $specialPageFactory
Definition: LinkRendererFactory.php:54
MediaWiki\Config\ServiceOptions
A class for passing options to services.
Definition: ServiceOptions.php:27
wfDeprecated
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
Definition: GlobalFunctions.php:997
MediaWiki\Linker
MediaWiki\Linker\LinkRendererFactory\__construct
__construct(TitleFormatter $titleFormatter, LinkCache $linkCache, SpecialPageFactory $specialPageFactory, HookContainer $hookContainer)
Definition: LinkRendererFactory.php:63
MediaWiki\Linker\LinkRendererFactory\$hookContainer
HookContainer $hookContainer
Definition: LinkRendererFactory.php:49
MediaWiki\Linker\LinkRendererFactory\$titleFormatter
TitleFormatter $titleFormatter
Definition: LinkRendererFactory.php:39
TitleFormatter
A title formatter service for MediaWiki.
Definition: TitleFormatter.php:35
MediaWiki\HookContainer\HookContainer
HookContainer class.
Definition: HookContainer.php:45
MediaWiki\Linker\LinkRendererFactory\createForUser
createForUser(UserIdentity $user)
Definition: LinkRendererFactory.php:97
PROTO_HTTP
const PROTO_HTTP
Definition: Defines.php:192
MediaWiki\Linker\LinkRendererFactory\$linkCache
LinkCache $linkCache
Definition: LinkRendererFactory.php:44