Translate extension for MediaWiki
 
All Classes Namespaces Files Functions Variables Modules Pages
Loading...
Searching...
No Matches
MessageBundleDependencyPurger.php
1<?php
2declare( strict_types = 1 );
3
4namespace MediaWiki\Extension\Translate\MessageBundleTranslation;
5
7use MediaWiki\Title\Title;
8
16 private TranslatableBundleFactory $bundleFactory;
17
18 public function __construct( TranslatableBundleFactory $bundleFactory ) {
19 $this->bundleFactory = $bundleFactory;
20 }
21
22 public function purge( Title $messageBundleTitle ): void {
23 // Ensure we are dealing with valid message bundle
24 $messageBundle = $this->bundleFactory->getValidBundle( $messageBundleTitle );
25 $offset = 0;
26
27 do {
28 $titlesWithThisMessageBundle = $messageBundle->getTitle()->getTemplateLinksTo(
29 [ 'LIMIT' => 500, 'OFFSET' => $offset ]
30 );
31
32 foreach ( $titlesWithThisMessageBundle as $title ) {
33 $title->invalidateCache();
34 }
35
36 $offset += 500;
37 } while ( count( $titlesWithThisMessageBundle ) === 500 );
38 }
39}
Create instances of various classes based on the type of TranslatableBundle.