MediaWiki  1.33.0
FakeConverter.php
Go to the documentation of this file.
1 <?php
38  public $mLang;
39 
40  function __construct( Language $langobj ) {
41  $this->mLang = $langobj;
42  }
43 
44  function autoConvert( $text, $variant = false ) {
45  return $text;
46  }
47 
48  function autoConvertToAllVariants( $text ) {
49  return [ $this->mLang->getCode() => $text ];
50  }
51 
52  function convert( $t ) {
53  return $t;
54  }
55 
56  function convertTo( $text, $variant ) {
57  return $text;
58  }
59 
64  function convertTitle( $t ) {
65  return $t->getPrefixedText();
66  }
67 
68  function convertNamespace( $ns ) {
69  return $this->mLang->getFormattedNsText( $ns );
70  }
71 
75  function getVariants() {
76  return [ $this->mLang->getCode() ];
77  }
78 
79  function getVariantFallbacks( $variant ) {
80  return $this->mLang->getCode();
81  }
82 
83  function getPreferredVariant() {
84  return $this->mLang->getCode();
85  }
86 
87  function getDefaultVariant() {
88  return $this->mLang->getCode();
89  }
90 
91  function getURLVariant() {
92  return '';
93  }
94 
95  function getConvRuleTitle() {
96  return false;
97  }
98 
99  function findVariantLink( &$l, &$n, $ignoreOtherCond = false ) {
100  }
101 
102  function getExtraHashOptions() {
103  return '';
104  }
105 
106  function getParsedTitle() {
107  return '';
108  }
109 
110  function markNoConversion( $text, $noParse = false ) {
111  return $text;
112  }
113 
114  function convertCategoryKey( $key ) {
115  return $key;
116  }
117 
118  function validateVariant( $variant = null ) {
119  if ( $variant === null ) {
120  return null;
121  }
122  $variant = strtolower( $variant );
123  return $variant === $this->mLang->getCode() ? $variant : null;
124  }
125 
126  function translate( $text, $variant ) {
127  return $text;
128  }
129 
130  public function updateConversionTable( Title $title ) {
131  }
132 
138  private function reloadTables() {
139  }
140 }
FakeConverter\convertCategoryKey
convertCategoryKey( $key)
Definition: FakeConverter.php:114
FakeConverter\translate
translate( $text, $variant)
Definition: FakeConverter.php:126
FakeConverter\autoConvertToAllVariants
autoConvertToAllVariants( $text)
Definition: FakeConverter.php:48
FakeConverter\markNoConversion
markNoConversion( $text, $noParse=false)
Definition: FakeConverter.php:110
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
FakeConverter\convert
convert( $t)
Definition: FakeConverter.php:52
FakeConverter\getConvRuleTitle
getConvRuleTitle()
Definition: FakeConverter.php:95
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:925
FakeConverter\validateVariant
validateVariant( $variant=null)
Definition: FakeConverter.php:118
FakeConverter\getExtraHashOptions
getExtraHashOptions()
Definition: FakeConverter.php:102
FakeConverter\convertTo
convertTo( $text, $variant)
Definition: FakeConverter.php:56
FakeConverter\getVariantFallbacks
getVariantFallbacks( $variant)
Definition: FakeConverter.php:79
FakeConverter\getVariants
getVariants()
Definition: FakeConverter.php:75
FakeConverter\__construct
__construct(Language $langobj)
Definition: FakeConverter.php:40
FakeConverter\$mLang
Language $mLang
Definition: FakeConverter.php:38
FakeConverter\reloadTables
reloadTables()
Used by test suites which need to reset the converter state.
Definition: FakeConverter.php:138
FakeConverter\getURLVariant
getURLVariant()
Definition: FakeConverter.php:91
FakeConverter\autoConvert
autoConvert( $text, $variant=false)
Definition: FakeConverter.php:44
FakeConverter
A fake language variant converter.
Definition: FakeConverter.php:34
Title
Represents a title within MediaWiki.
Definition: Title.php:40
FakeConverter\findVariantLink
findVariantLink(&$l, &$n, $ignoreOtherCond=false)
Definition: FakeConverter.php:99
FakeConverter\updateConversionTable
updateConversionTable(Title $title)
Definition: FakeConverter.php:130
FakeConverter\getParsedTitle
getParsedTitle()
Definition: FakeConverter.php:106
FakeConverter\getPreferredVariant
getPreferredVariant()
Definition: FakeConverter.php:83
$t
$t
Definition: testCompression.php:69
FakeConverter\convertNamespace
convertNamespace( $ns)
Definition: FakeConverter.php:68
FakeConverter\getDefaultVariant
getDefaultVariant()
Definition: FakeConverter.php:87
Language
Internationalisation code.
Definition: Language.php:36
FakeConverter\convertTitle
convertTitle( $t)
Definition: FakeConverter.php:64