MediaWiki master
LinkRendererFactory.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\Linker;
22
28
34
38 private $titleFormatter;
39
43 private $linkCache;
44
48 private $hookContainer;
49
53 private $specialPageFactory;
54
62 public function __construct(
63 TitleFormatter $titleFormatter,
64 LinkCache $linkCache,
65 SpecialPageFactory $specialPageFactory,
66 HookContainer $hookContainer
67 ) {
68 $this->titleFormatter = $titleFormatter;
69 $this->linkCache = $linkCache;
70 $this->specialPageFactory = $specialPageFactory;
71 $this->hookContainer = $hookContainer;
72 }
73
82 public function create( array $options = [ 'renderForComment' => false ] ) {
83 return new LinkRenderer(
84 $this->titleFormatter, $this->linkCache, $this->specialPageFactory,
85 $this->hookContainer,
87 );
88 }
89
94 public function createFromLegacyOptions( array $options ) {
95 $linkRenderer = $this->create();
96
97 if ( in_array( 'forcearticlepath', $options, true ) ) {
98 $linkRenderer->setForceArticlePath( true );
99 }
100
101 if ( in_array( 'http', $options, true ) ) {
102 $linkRenderer->setExpandURLs( PROTO_HTTP );
103 } elseif ( in_array( 'https', $options, true ) ) {
104 $linkRenderer->setExpandURLs( PROTO_HTTPS );
105 }
106
107 return $linkRenderer;
108 }
109}
const PROTO_HTTPS
Definition Defines.php:204
const PROTO_HTTP
Definition Defines.php:203
Cache for article titles (prefixed DB keys) and ids linked from one source.
Definition LinkCache.php:52
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)
Class that generates HTML for internal links.
Factory for handling the special page list and generating SpecialPage objects.
A title formatter service for MediaWiki.