21 private $translatablePageStore;
23 private $messageBundleStore;
25 public function __construct(
29 $this->translatablePageStore = $translatablePageStore;
30 $this->messageBundleStore = $messageBundleStore;
36 $translatablePage = TranslatablePage::newFromTitle( $title );
37 return $translatablePage;
38 } elseif ( MessageBundle::isSourcePage( $title ) ) {
40 return $messageBundle;
48 $bundle = $this->getBundle( $title );
53 throw new InvalidArgumentException(
"{$title->getPrefixedText()} is not a TranslatableBundle" );
56 public function getBundleFromClass( Title $title,
string $bundleType ): TranslatableBundle {
57 if ( $bundleType === MessageBundle::class ) {
58 return new MessageBundle( $title );
60 return TranslatablePage::newFromTitle( $title );
64 public function getPageMoveLogger( TranslatableBundle $bundle ): PageMoveLogger {
65 if ( $bundle instanceof TranslatablePage ) {
66 return new PageMoveLogger( $bundle->getTitle(),
'pagetranslation' );
67 } elseif ( $bundle instanceof MessageBundle ) {
68 return new PageMoveLogger( $bundle->getTitle(),
'messagebundle' );
71 throw new InvalidArgumentException(
"Unknown TranslatableBundle type: " . get_class( $bundle ) );
74 public function getPageDeleteLogger( TranslatableBundle $bundle ): PageDeleteLogger {
75 if ( $bundle instanceof TranslatablePage ) {
76 return new PageDeleteLogger( $bundle->getTitle(),
'pagetranslation' );
77 } elseif ( $bundle instanceof MessageBundle ) {
78 return new PageDeleteLogger( $bundle->getTitle(),
'messagebundle' );
81 throw new InvalidArgumentException(
"Unknown TranslatableBundle type: " . get_class( $bundle ) );
84 public function getStore( TranslatableBundle $bundle ): TranslatableBundleStore {
85 if ( $bundle instanceof TranslatablePage ) {
86 return $this->translatablePageStore;
87 } elseif ( $bundle instanceof MessageBundle ) {
88 return $this->messageBundleStore;
91 throw new InvalidArgumentException(
"Unknown TranslatableBundle type: " . get_class( $bundle ) );