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
;
28 * Factory to create LinkRender objects
31 class LinkRendererFactory
{
36 private $titleFormatter;
44 * @param TitleFormatter $titleFormatter
45 * @param LinkCache $linkCache
47 public function __construct( TitleFormatter
$titleFormatter, LinkCache
$linkCache ) {
48 $this->titleFormatter
= $titleFormatter;
49 $this->linkCache
= $linkCache;
53 * @return LinkRenderer
55 public function create() {
56 return new LinkRenderer( $this->titleFormatter
, $this->linkCache
);
61 * @return LinkRenderer
63 public function createForUser( User
$user ) {
64 $linkRenderer = $this->create();
65 $linkRenderer->setStubThreshold( $user->getStubThreshold() );
71 * @param array $options
72 * @return LinkRenderer
74 public function createFromLegacyOptions( array $options ) {
75 $linkRenderer = $this->create();
77 if ( in_array( 'forcearticlepath', $options, true ) ) {
78 $linkRenderer->setForceArticlePath( true );
81 if ( in_array( 'http', $options, true ) ) {
82 $linkRenderer->setExpandURLs( PROTO_HTTP
);
83 } elseif ( in_array( 'https', $options, true ) ) {
84 $linkRenderer->setExpandURLs( PROTO_HTTPS
);
87 if ( isset( $options['stubThreshold'] ) ) {
88 $linkRenderer->setStubThreshold(
89 $options['stubThreshold']