X-Git-Url: https://scripts.mit.edu/gitweb/autoinstallsdev/mediawiki.git/blobdiff_plain/19e297c21b10b1b8a3acad5e73fc71dcb35db44a..6932310fd58ebef145fa01eb76edf7150284d8ea:/includes/title/SubpageImportTitleFactory.php diff --git a/includes/title/SubpageImportTitleFactory.php b/includes/title/SubpageImportTitleFactory.php new file mode 100644 index 00000000..b0be7afa --- /dev/null +++ b/includes/title/SubpageImportTitleFactory.php @@ -0,0 +1,55 @@ +getNamespace() ) ) { + throw new MWException( "The root page you specified, $rootPage, is in a " . + "namespace where subpages are not allowed" ); + } + $this->rootPage = $rootPage; + } + + /** + * Determines which local title best corresponds to the given foreign title. + * If such a title can't be found or would be locally invalid, null is + * returned. + * + * @param ForeignTitle $foreignTitle The ForeignTitle to convert + * @return Title|null + */ + public function createTitleFromForeignTitle( ForeignTitle $foreignTitle ) { + return Title::newFromText( $this->rootPage->getPrefixedDBkey() . '/' . + $foreignTitle->getFullText() ); + } +}