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
;
29 * Factory to create LinkRender objects
32 class LinkRendererFactory
{
37 private $titleFormatter;
45 * @param TitleFormatter $titleFormatter
46 * @param LinkCache $linkCache
48 public function __construct( TitleFormatter
$titleFormatter, LinkCache
$linkCache ) {
49 $this->titleFormatter
= $titleFormatter;
50 $this->linkCache
= $linkCache;
54 * @return LinkRenderer
56 public function create() {
57 return new LinkRenderer( $this->titleFormatter
, $this->linkCache
);
62 * @return LinkRenderer
64 public function createForUser( User
$user ) {
65 $linkRenderer = $this->create();
66 $linkRenderer->setStubThreshold( $user->getStubThreshold() );
72 * @param array $options
73 * @return LinkRenderer
75 public function createFromLegacyOptions( array $options ) {
76 $linkRenderer = $this->create();
78 if ( in_array( 'forcearticlepath', $options, true ) ) {
79 $linkRenderer->setForceArticlePath( true );
82 if ( in_array( 'http', $options, true ) ) {
83 $linkRenderer->setExpandURLs( PROTO_HTTP
);
84 } elseif ( in_array( 'https', $options, true ) ) {
85 $linkRenderer->setExpandURLs( PROTO_HTTPS
);
88 if ( isset( $options['stubThreshold'] ) ) {
89 $linkRenderer->setStubThreshold(
90 $options['stubThreshold']