eeb28b5560ccf1a05a467596a8a369446bb2672d
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
19 * @author Kunal Mehta <legoktm@member.fsf.org>
21 namespace MediaWiki\Linker
;
29 * Factory to create LinkRender objects
32 class LinkRendererFactory
{
37 private $titleFormatter;
50 * @param TitleFormatter $titleFormatter
51 * @param LinkCache $linkCache
52 * @param NamespaceInfo $nsInfo
54 public function __construct(
55 TitleFormatter
$titleFormatter, LinkCache
$linkCache, NamespaceInfo
$nsInfo
57 $this->titleFormatter
= $titleFormatter;
58 $this->linkCache
= $linkCache;
59 $this->nsInfo
= $nsInfo;
63 * @return LinkRenderer
65 public function create() {
66 return new LinkRenderer( $this->titleFormatter
, $this->linkCache
, $this->nsInfo
);
71 * @return LinkRenderer
73 public function createForUser( User
$user ) {
74 $linkRenderer = $this->create();
75 $linkRenderer->setStubThreshold( $user->getStubThreshold() );
81 * @param array $options
82 * @return LinkRenderer
84 public function createFromLegacyOptions( array $options ) {
85 $linkRenderer = $this->create();
87 if ( in_array( 'forcearticlepath', $options, true ) ) {
88 $linkRenderer->setForceArticlePath( true );
91 if ( in_array( 'http', $options, true ) ) {
92 $linkRenderer->setExpandURLs( PROTO_HTTP
);
93 } elseif ( in_array( 'https', $options, true ) ) {
94 $linkRenderer->setExpandURLs( PROTO_HTTPS
);
97 if ( isset( $options['stubThreshold'] ) ) {
98 $linkRenderer->setStubThreshold(
99 $options['stubThreshold']
103 return $linkRenderer;