Localisation updates from https://translatewiki.net.
[mediawiki.git] / includes / title / TitleFactory.php
blobb9d590ef6ef256036702cfb2d97f445883631485
1 <?php
2 /**
3 * Factory for creating Title objects without static coupling.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
20 * @file
23 namespace MediaWiki\Title;
25 use MediaWiki\Linker\LinkTarget;
26 use MediaWiki\Page\PageIdentity;
27 use MediaWiki\Page\PageReference;
28 use MessageLocalizer;
29 use Wikimedia\Rdbms\IResultWrapper;
31 /**
32 * Creates Title objects.
34 * For now, there is nothing interesting in this class. It is meant for preventing static Title
35 * methods causing problems in unit tests.
37 * @since 1.35
39 class TitleFactory {
41 /**
42 * @see Title::newFromDBkey
43 * @param string $key
44 * @return Title|null
46 public function newFromDBkey( $key ): ?Title {
47 return Title::newFromDBkey( $key );
50 /**
51 * @see Title::newFromLinkTarget
52 * @param LinkTarget $linkTarget
53 * @param string $forceClone
54 * @return Title
56 public function newFromLinkTarget( LinkTarget $linkTarget, $forceClone = '' ): Title {
57 return Title::newFromLinkTarget( $linkTarget, $forceClone );
60 /**
61 * @see Title::castFromLinkTarget
62 * @param LinkTarget|null $linkTarget
63 * @return Title|null
65 public function castFromLinkTarget( ?LinkTarget $linkTarget ): ?Title {
66 return Title::castFromLinkTarget( $linkTarget );
69 /**
70 * @see Title::newFromPageIdentity
71 * @since 1.41
72 * @param PageIdentity $pageIdentity
73 * @return Title
75 public function newFromPageIdentity( PageIdentity $pageIdentity ): Title {
76 return Title::newFromPageIdentity( $pageIdentity );
79 /**
80 * @see Title::castFromPageIdentity
81 * @since 1.36
82 * @param PageIdentity|null $pageIdentity
83 * @return Title|null
85 public function castFromPageIdentity( ?PageIdentity $pageIdentity ): ?Title {
86 return Title::castFromPageIdentity( $pageIdentity );
89 /**
90 * @see Title::newFromPageReference
91 * @since 1.41
92 * @param PageReference $pageReference
93 * @return Title
95 public function newFromPageReference( PageReference $pageReference ): Title {
96 return Title::newFromPageReference( $pageReference );
99 /**
100 * @see Title::castFromPageReference
101 * @since 1.37
102 * @param PageReference|null $pageReference
103 * @return Title|null
105 public function castFromPageReference( ?PageReference $pageReference ): ?Title {
106 return Title::castFromPageReference( $pageReference );
110 * @see Title::newFromText
111 * @param string|int|null $text
112 * @param int $defaultNamespace
113 * @return Title|null
114 * @throws \InvalidArgumentException
116 public function newFromText( $text, $defaultNamespace = NS_MAIN ): ?Title {
117 return Title::newFromText( $text, $defaultNamespace );
121 * @see Title::newFromTextThrow
122 * @param string $text
123 * @param int $defaultNamespace
124 * @return Title
125 * @throws MalformedTitleException
127 public function newFromTextThrow( $text, $defaultNamespace = NS_MAIN ): Title {
128 return Title::newFromTextThrow( $text, $defaultNamespace );
132 * @see Title::newFromURL
133 * @param string $url
134 * @return Title|null
136 public function newFromURL( $url ): ?Title {
137 return Title::newFromURL( $url );
141 * @see Title::newFromID
142 * @param int $id
143 * @param int $flags
144 * @return Title|null
146 public function newFromID( $id, $flags = 0 ): ?Title {
147 return Title::newFromID( $id, $flags );
151 * @see Title::newFromRow
152 * @param \stdClass $row
153 * @return Title
155 public function newFromRow( $row ): Title {
156 return Title::newFromRow( $row );
160 * @see Title::makeTitle
161 * @param int $ns
162 * @param string $title
163 * @param string $fragment
164 * @param string $interwiki
165 * @return Title
167 public function makeTitle( $ns, $title, $fragment = '', $interwiki = '' ): Title {
168 return Title::makeTitle( $ns, $title, $fragment, $interwiki );
172 * @see Title::makeTitleSafe
173 * @param int $ns
174 * @param string $title
175 * @param string $fragment
176 * @param string $interwiki
177 * @return Title|null
179 public function makeTitleSafe( $ns, $title, $fragment = '', $interwiki = '' ): ?Title {
180 return Title::makeTitleSafe( $ns, $title, $fragment, $interwiki );
184 * @see Title::newMainPage
185 * @param MessageLocalizer|null $localizer
186 * @return Title
188 public function newMainPage( ?MessageLocalizer $localizer = null ): Title {
189 return Title::newMainPage( $localizer );
193 * @since 1.42
194 * @param IResultWrapper $result
195 * @return TitleArrayFromResult
197 public function newTitleArrayFromResult( IResultWrapper $result ) {
198 return new TitleArrayFromResult( $result );
203 /** @deprecated class alias since 1.41 */
204 class_alias( TitleFactory::class, 'TitleFactory' );