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
23 namespace MediaWiki\Title
;
25 use MediaWiki\Linker\LinkTarget
;
26 use MediaWiki\Page\PageIdentity
;
27 use MediaWiki\Page\PageReference
;
29 use Wikimedia\Rdbms\IResultWrapper
;
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.
42 * @see Title::newFromDBkey
46 public function newFromDBkey( $key ): ?Title
{
47 return Title
::newFromDBkey( $key );
51 * @see Title::newFromLinkTarget
52 * @param LinkTarget $linkTarget
53 * @param string $forceClone
56 public function newFromLinkTarget( LinkTarget
$linkTarget, $forceClone = '' ): Title
{
57 return Title
::newFromLinkTarget( $linkTarget, $forceClone );
61 * @see Title::castFromLinkTarget
62 * @param LinkTarget|null $linkTarget
65 public function castFromLinkTarget( ?LinkTarget
$linkTarget ): ?Title
{
66 return Title
::castFromLinkTarget( $linkTarget );
70 * @see Title::newFromPageIdentity
72 * @param PageIdentity $pageIdentity
75 public function newFromPageIdentity( PageIdentity
$pageIdentity ): Title
{
76 return Title
::newFromPageIdentity( $pageIdentity );
80 * @see Title::castFromPageIdentity
82 * @param PageIdentity|null $pageIdentity
85 public function castFromPageIdentity( ?PageIdentity
$pageIdentity ): ?Title
{
86 return Title
::castFromPageIdentity( $pageIdentity );
90 * @see Title::newFromPageReference
92 * @param PageReference $pageReference
95 public function newFromPageReference( PageReference
$pageReference ): Title
{
96 return Title
::newFromPageReference( $pageReference );
100 * @see Title::castFromPageReference
102 * @param PageReference|null $pageReference
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
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
125 * @throws MalformedTitleException
127 public function newFromTextThrow( $text, $defaultNamespace = NS_MAIN
): Title
{
128 return Title
::newFromTextThrow( $text, $defaultNamespace );
132 * @see Title::newFromURL
136 public function newFromURL( $url ): ?Title
{
137 return Title
::newFromURL( $url );
141 * @see Title::newFromID
146 public function newFromID( $id, $flags = 0 ): ?Title
{
147 return Title
::newFromID( $id, $flags );
151 * @see Title::newFromRow
152 * @param \stdClass $row
155 public function newFromRow( $row ): Title
{
156 return Title
::newFromRow( $row );
160 * @see Title::makeTitle
162 * @param string $title
163 * @param string $fragment
164 * @param string $interwiki
167 public function makeTitle( $ns, $title, $fragment = '', $interwiki = '' ): Title
{
168 return Title
::makeTitle( $ns, $title, $fragment, $interwiki );
172 * @see Title::makeTitleSafe
174 * @param string $title
175 * @param string $fragment
176 * @param string $interwiki
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
188 public function newMainPage( ?MessageLocalizer
$localizer = null ): Title
{
189 return Title
::newMainPage( $localizer );
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' );