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
20 * @author Kunal Mehta <legoktm@member.fsf.org>
22 namespace MediaWiki\Linker
;
28 * Factory to create LinkRender objects
31 class LinkRendererFactory
{
36 private $titleFormatter;
39 * @param TitleFormatter $titleFormatter
41 public function __construct( TitleFormatter
$titleFormatter ) {
42 $this->titleFormatter
= $titleFormatter;
46 * @return LinkRenderer
48 public function create() {
49 return new LinkRenderer( $this->titleFormatter
);
54 * @return LinkRenderer
56 public function createForUser( User
$user ) {
57 $linkRenderer = $this->create();
58 $linkRenderer->setStubThreshold( $user->getStubThreshold() );
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']