Expose $wgMaxArticleSize in siteinfo query api
[mediawiki.git] / includes / linker / LinkRendererFactory.php
blob7124be1e994913c4731805d4f9016388b4f25986
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
18 * @file
19 * @license GPL-2.0+
20 * @author Kunal Mehta <legoktm@member.fsf.org>
22 namespace MediaWiki\Linker;
24 use TitleFormatter;
25 use User;
27 /**
28 * Factory to create LinkRender objects
29 * @since 1.28
31 class LinkRendererFactory {
33 /**
34 * @var TitleFormatter
36 private $titleFormatter;
38 /**
39 * @param TitleFormatter $titleFormatter
41 public function __construct( TitleFormatter $titleFormatter ) {
42 $this->titleFormatter = $titleFormatter;
45 /**
46 * @return LinkRenderer
48 public function create() {
49 return new LinkRenderer( $this->titleFormatter );
52 /**
53 * @param User $user
54 * @return LinkRenderer
56 public function createForUser( User $user ) {
57 $linkRenderer = $this->create();
58 $linkRenderer->setStubThreshold( $user->getStubThreshold() );
60 return $linkRenderer;
63 /**
64 * @param array $options
65 * @return LinkRenderer
67 public function createFromLegacyOptions( array $options ) {
68 $linkRenderer = $this->create();
70 if ( in_array( 'forcearticlepath', $options, true ) ) {
71 $linkRenderer->setForceArticlePath( true );
74 if ( in_array( 'http', $options, true ) ) {
75 $linkRenderer->setExpandURLs( PROTO_HTTP );
76 } elseif ( in_array( 'https', $options, true ) ) {
77 $linkRenderer->setExpandURLs( PROTO_HTTPS );
80 if ( isset( $options['stubThreshold'] ) ) {
81 $linkRenderer->setStubThreshold(
82 $options['stubThreshold']
86 return $linkRenderer;