Merge "Bump Mustache from 1.0.0 to 3.0.1"
[lhc/web/wiklou.git] / includes / parser / ParserFactory.php
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.
7 *
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.
12 *
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
17 *
18 * @file
19 * @ingroup Parser
20 */
21 use MediaWiki\Linker\LinkRendererFactory;
22
23 use MediaWiki\Special\SpecialPageFactory;
24
25 /**
26 * @since 1.32
27 */
28 class ParserFactory {
29 /** @var array */
30 private $parserConf;
31
32 /** @var MagicWordFactory */
33 private $magicWordFactory;
34
35 /** @var Language */
36 private $contLang;
37
38 /** @var string */
39 private $urlProtocols;
40
41 /** @var SpecialPageFactory */
42 private $specialPageFactory;
43
44 /** @var Config */
45 private $siteConfig;
46
47 /** @var LinkRendererFactory */
48 private $linkRendererFactory;
49
50 /**
51 * @param array $parserConf See $wgParserConf documentation
52 * @param MagicWordFactory $magicWordFactory
53 * @param Language $contLang Content language
54 * @param string $urlProtocols As returned from wfUrlProtocols()
55 * @param SpecialPageFactory $spFactory
56 * @param Config $siteConfig
57 * @param LinkRendererFactory $linkRendererFactory
58 * @since 1.32
59 */
60 public function __construct(
61 array $parserConf, MagicWordFactory $magicWordFactory, Language $contLang, $urlProtocols,
62 SpecialPageFactory $spFactory, Config $siteConfig, LinkRendererFactory $linkRendererFactory
63 ) {
64 $this->parserConf = $parserConf;
65 $this->magicWordFactory = $magicWordFactory;
66 $this->contLang = $contLang;
67 $this->urlProtocols = $urlProtocols;
68 $this->specialPageFactory = $spFactory;
69 $this->siteConfig = $siteConfig;
70 $this->linkRendererFactory = $linkRendererFactory;
71 }
72
73 /**
74 * @return Parser
75 * @since 1.32
76 */
77 public function create() : Parser {
78 return new Parser( $this->parserConf, $this->magicWordFactory, $this->contLang, $this,
79 $this->urlProtocols, $this->specialPageFactory, $this->siteConfig,
80 $this->linkRendererFactory );
81 }
82 }