Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
|||
| 1 | <?php |
| 2 | |
| 3 | declare( strict_types=1 ); |
| 4 | |
| 5 | use ContentTranslation\AbuseFilterChecker; |
| 6 | use ContentTranslation\CategoryStore; |
| 7 | use ContentTranslation\ConnectionProvider; |
| 8 | use ContentTranslation\LogNames; |
| 9 | use ContentTranslation\Manager\TranslationCorporaManager; |
| 10 | use ContentTranslation\ParsoidClientFactory; |
| 11 | use ContentTranslation\PreferenceHelper; |
| 12 | use ContentTranslation\Service\ContentCompressionService; |
| 13 | use ContentTranslation\Service\CxServerClient; |
| 14 | use ContentTranslation\Service\EditedSectionFinder; |
| 15 | use ContentTranslation\Service\SandboxTitleMaker; |
| 16 | use ContentTranslation\Service\SectionContentEvaluator; |
| 17 | use ContentTranslation\Service\SectionMappingFetcher; |
| 18 | use ContentTranslation\Service\SectionPositionCalculator; |
| 19 | use ContentTranslation\Service\SectionTitleFetcher; |
| 20 | use ContentTranslation\Service\TranslationSplitter; |
| 21 | use ContentTranslation\Service\TranslationTargetUrlCreator; |
| 22 | use ContentTranslation\Service\TranslatorService; |
| 23 | use ContentTranslation\Service\UserPermissionChecker; |
| 24 | use ContentTranslation\Service\UserService; |
| 25 | use ContentTranslation\Service\WikidataIdFetcher; |
| 26 | use ContentTranslation\Store\FavoriteSuggestionStore; |
| 27 | use ContentTranslation\Store\RecentSignificantEditStore; |
| 28 | use ContentTranslation\Store\SectionTranslationStore; |
| 29 | use ContentTranslation\Store\TranslationCorporaStore; |
| 30 | use ContentTranslation\Store\TranslationStore; |
| 31 | use ContentTranslation\Store\TranslatorStore; |
| 32 | use ContentTranslation\Validator\TranslationUnitValidator; |
| 33 | use MediaWiki\Config\Config; |
| 34 | use MediaWiki\Config\ServiceOptions; |
| 35 | use MediaWiki\Logger\LoggerFactory; |
| 36 | use MediaWiki\MediaWikiServices; |
| 37 | use MediaWiki\Registration\ExtensionRegistry; |
| 38 | use MediaWiki\WikiMap\WikiMap; |
| 39 | use Wikimedia\Rdbms\IConnectionProvider; |
| 40 | use Wikimedia\Services\NoSuchServiceException; |
| 41 | |
| 42 | // PHP unit does not understand code coverage for this file |
| 43 | // as the @covers annotation cannot cover a specific file |
| 44 | // This is fully tested in ServiceWiringTest.php |
| 45 | // @codeCoverageIgnoreStart |
| 46 | |
| 47 | /** @phpcs-require-sorted-array */ |
| 48 | return [ |
| 49 | 'ContentTranslation.AbuseFilterChecker' => |
| 50 | static function ( MediaWikiServices $services ): AbuseFilterChecker { |
| 51 | try { |
| 52 | $variableGeneratorFactory = $services->getService( 'AbuseFilterVariableGeneratorFactory' ); |
| 53 | $consequencesLookup = $services->getService( 'AbuseFilterConsequencesLookup' ); |
| 54 | $filterLookup = $services->getService( 'AbuseFilterFilterLookup' ); |
| 55 | $filterRunnerFactory = $services->getService( 'AbuseFilterFilterRunnerFactory' ); |
| 56 | } catch ( NoSuchServiceException ) { |
| 57 | $variableGeneratorFactory = null; |
| 58 | $consequencesLookup = null; |
| 59 | $filterLookup = null; |
| 60 | $filterRunnerFactory = null; |
| 61 | } |
| 62 | return new AbuseFilterChecker( |
| 63 | ExtensionRegistry::getInstance()->isLoaded( 'Abuse Filter' ), |
| 64 | $services->getWikiPageFactory(), |
| 65 | $variableGeneratorFactory, |
| 66 | $consequencesLookup, |
| 67 | $filterLookup, |
| 68 | $filterRunnerFactory |
| 69 | ); |
| 70 | }, |
| 71 | 'ContentTranslation.CategoryStore' => |
| 72 | static function ( MediaWikiServices $services ): CategoryStore { |
| 73 | return new CategoryStore( $services->getService( 'ContentTranslation.ConnectionProvider' ) ); |
| 74 | }, |
| 75 | 'ContentTranslation.CommunityConfiguration' => |
| 76 | static function ( MediaWikiServices $services ): Config { |
| 77 | if ( ExtensionRegistry::getInstance()->isLoaded( 'CommunityConfiguration' ) ) { |
| 78 | return $services->getService( 'CommunityConfiguration.MediaWikiConfigRouter' ); |
| 79 | } else { |
| 80 | return $services->getMainConfig(); |
| 81 | } |
| 82 | }, |
| 83 | 'ContentTranslation.ConnectionProvider' => static function ( MediaWikiServices $services ): IConnectionProvider { |
| 84 | return new ConnectionProvider( $services->getConnectionProvider() ); |
| 85 | }, |
| 86 | 'ContentTranslation.ContentCompressionService' => |
| 87 | static function (): ContentCompressionService { |
| 88 | return new ContentCompressionService(); |
| 89 | }, |
| 90 | 'ContentTranslation.CxServerClient' => |
| 91 | static function ( MediaWikiServices $services ): CxServerClient { |
| 92 | return new CxServerClient( |
| 93 | $services->getHttpRequestFactory(), |
| 94 | LoggerFactory::getInstance( LogNames::MAIN ), |
| 95 | new ServiceOptions( CxServerClient::CONSTRUCTOR_OPTIONS, $services->getMainConfig() ) |
| 96 | ); |
| 97 | }, |
| 98 | 'ContentTranslation.EditedSectionFinder' => |
| 99 | static function (): EditedSectionFinder { |
| 100 | return new EditedSectionFinder(); |
| 101 | }, |
| 102 | 'ContentTranslation.FavoriteSuggestionStore' => |
| 103 | static function ( MediaWikiServices $services ): FavoriteSuggestionStore { |
| 104 | return new FavoriteSuggestionStore( $services->getService( 'ContentTranslation.ConnectionProvider' ) ); |
| 105 | }, |
| 106 | 'ContentTranslation.ParsoidClientFactory' => static function ( |
| 107 | MediaWikiServices $services |
| 108 | ): ParsoidClientFactory { |
| 109 | return new ParsoidClientFactory( |
| 110 | $services->getPageRestHelperFactory() |
| 111 | ); |
| 112 | }, |
| 113 | 'ContentTranslation.PreferenceHelper' => |
| 114 | static function ( MediaWikiServices $services ): PreferenceHelper { |
| 115 | return new PreferenceHelper( |
| 116 | $services->getPreferencesFactory(), |
| 117 | $services->getUserOptionsLookup(), |
| 118 | new ServiceOptions( PreferenceHelper::CONSTRUCTOR_OPTIONS, $services->getMainConfig() ), |
| 119 | ExtensionRegistry::getInstance()->isLoaded( 'BetaFeatures' ), |
| 120 | ExtensionRegistry::getInstance()->isLoaded( 'GlobalPreferences' ) |
| 121 | ); |
| 122 | }, |
| 123 | 'ContentTranslation.RecentSignificantEditStore' => |
| 124 | static function ( MediaWikiServices $services ): RecentSignificantEditStore { |
| 125 | global $wgConf; |
| 126 | [ $wikiFamily ] = $wgConf->siteFromDB( WikiMap::getCurrentWikiId() ); |
| 127 | return new RecentSignificantEditStore( |
| 128 | $services->getService( 'ContentTranslation.ConnectionProvider' ), |
| 129 | $wikiFamily |
| 130 | ); |
| 131 | }, |
| 132 | 'ContentTranslation.SandboxTitleMaker' => |
| 133 | static function ( MediaWikiServices $services ): SandboxTitleMaker { |
| 134 | $isSandboxLinkLoaded = ExtensionRegistry::getInstance()->isLoaded( 'SandboxLink' ); |
| 135 | return new SandboxTitleMaker( $services->getTitleFactory(), $isSandboxLinkLoaded ); |
| 136 | }, |
| 137 | 'ContentTranslation.SectionContentEvaluator' => |
| 138 | static function ( MediaWikiServices $services ): SectionContentEvaluator { |
| 139 | return new SectionContentEvaluator( |
| 140 | $services->getWikiPageFactory(), |
| 141 | $services->getService( 'ContentTranslation.ParsoidClientFactory' ) |
| 142 | ); |
| 143 | }, |
| 144 | 'ContentTranslation.SectionMappingFetcher' => |
| 145 | static function ( MediaWikiServices $services ): SectionMappingFetcher { |
| 146 | return new SectionMappingFetcher( |
| 147 | $services->getService( 'ContentTranslation.CxServerClient' ), |
| 148 | LoggerFactory::getInstance( LogNames::MAIN ) |
| 149 | ); |
| 150 | }, |
| 151 | 'ContentTranslation.SectionPositionCalculator' => |
| 152 | static function ( MediaWikiServices $services ): SectionPositionCalculator { |
| 153 | return new SectionPositionCalculator( |
| 154 | $services->getService( 'ContentTranslation.CxServerClient' ), |
| 155 | $services->getService( 'ContentTranslation.SectionTitleFetcher' ), |
| 156 | $services->getService( 'ContentTranslation.SectionMappingFetcher' ), |
| 157 | ); |
| 158 | }, |
| 159 | 'ContentTranslation.SectionTitleFetcher' => |
| 160 | static function ( MediaWikiServices $services ): SectionTitleFetcher { |
| 161 | return new SectionTitleFetcher( |
| 162 | $services->getHttpRequestFactory(), |
| 163 | LoggerFactory::getInstance( LogNames::MAIN ) |
| 164 | ); |
| 165 | }, |
| 166 | 'ContentTranslation.SectionTranslationStore' => |
| 167 | static function ( MediaWikiServices $services ): SectionTranslationStore { |
| 168 | return new SectionTranslationStore( |
| 169 | $services->getService( 'ContentTranslation.ConnectionProvider' ) |
| 170 | ); |
| 171 | }, |
| 172 | 'ContentTranslation.TranslationCorporaManager' => |
| 173 | static function ( MediaWikiServices $services ): TranslationCorporaManager { |
| 174 | return new TranslationCorporaManager( |
| 175 | $services->getService( 'ContentTranslation.TranslationCorporaStore' ) |
| 176 | ); |
| 177 | }, |
| 178 | 'ContentTranslation.TranslationCorporaStore' => |
| 179 | static function ( MediaWikiServices $services ): TranslationCorporaStore { |
| 180 | return new TranslationCorporaStore( |
| 181 | $services->getService( 'ContentTranslation.ConnectionProvider' ), |
| 182 | LoggerFactory::getInstance( LogNames::MAIN ), |
| 183 | $services->getService( 'ContentTranslation.ContentCompressionService' ) |
| 184 | ); |
| 185 | }, |
| 186 | 'ContentTranslation.TranslationSplitter' => |
| 187 | static function ( MediaWikiServices $services ): TranslationSplitter { |
| 188 | return new TranslationSplitter( |
| 189 | $services->getService( 'ContentTranslation.TranslationCorporaManager' ), |
| 190 | $services->getService( 'ContentTranslation.SectionTitleFetcher' ) |
| 191 | ); |
| 192 | }, |
| 193 | 'ContentTranslation.TranslationStore' => |
| 194 | static function ( MediaWikiServices $services ): TranslationStore { |
| 195 | return new TranslationStore( |
| 196 | $services->getService( 'ContentTranslation.ConnectionProvider' ), |
| 197 | $services->getService( 'ContentTranslation.UserService' ) |
| 198 | ); |
| 199 | }, |
| 200 | 'ContentTranslation.TranslationTargetUrlCreator' => |
| 201 | static function ( MediaWikiServices $services ): TranslationTargetUrlCreator { |
| 202 | return new TranslationTargetUrlCreator( |
| 203 | $services->getTitleFactory(), |
| 204 | new ServiceOptions( TranslationTargetUrlCreator::CONSTRUCTOR_OPTIONS, $services->getMainConfig() ) |
| 205 | ); |
| 206 | }, |
| 207 | 'ContentTranslation.TranslationUnitValidator' => |
| 208 | static function ( MediaWikiServices $services ): TranslationUnitValidator { |
| 209 | return new TranslationUnitValidator( |
| 210 | $services->getService( 'ContentTranslation.AbuseFilterChecker' ), |
| 211 | $services->getService( 'ContentTranslation.ParsoidClientFactory' ) |
| 212 | ); |
| 213 | }, |
| 214 | 'ContentTranslation.TranslatorService' => |
| 215 | static function ( MediaWikiServices $services ): TranslatorService { |
| 216 | return new TranslatorService( |
| 217 | $services->getService( 'ContentTranslation.UserService' ), |
| 218 | $services->getService( 'ContentTranslation.TranslationStore' ) |
| 219 | ); |
| 220 | }, |
| 221 | 'ContentTranslation.TranslatorStore' => |
| 222 | static function ( MediaWikiServices $services ): TranslatorStore { |
| 223 | return new TranslatorStore( |
| 224 | $services->getService( 'ContentTranslation.ConnectionProvider' ), |
| 225 | $services->getService( 'ContentTranslation.UserService' ) |
| 226 | ); |
| 227 | }, |
| 228 | 'ContentTranslation.UserPermissionChecker' => |
| 229 | static function ( MediaWikiServices $services ): UserPermissionChecker { |
| 230 | return new UserPermissionChecker( |
| 231 | $services->getTitleFactory(), |
| 232 | $services->getUserGroupManager(), |
| 233 | new ServiceOptions( |
| 234 | UserPermissionChecker::CONSTRUCTOR_OPTIONS, |
| 235 | $services->getMainConfig() |
| 236 | ) |
| 237 | ); |
| 238 | }, |
| 239 | 'ContentTranslation.UserService' => |
| 240 | static function ( MediaWikiServices $services ): UserService { |
| 241 | return new UserService( $services->getCentralIdLookup(), $services->getGenderCache() ); |
| 242 | }, |
| 243 | 'ContentTranslation.WikidataIdFetcher' => |
| 244 | static function ( MediaWikiServices $services ): WikidataIdFetcher { |
| 245 | return new WikidataIdFetcher( $services->getHttpRequestFactory() ); |
| 246 | } |
| 247 | ]; |
| 248 | |
| 249 | // @codeCoverageIgnoreEnd |