Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 17 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| BetaPreferenceHooks | |
0.00% |
0 / 17 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| onGetBetaFeaturePreferences | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace MediaWiki\Extension\VisualEditor; |
| 4 | |
| 5 | use MediaWiki\Config\Config; |
| 6 | use MediaWiki\Config\ConfigFactory; |
| 7 | use MediaWiki\Extension\BetaFeatures\Hooks\GetBetaFeaturePreferencesHook; |
| 8 | use MediaWiki\MainConfigNames; |
| 9 | use MediaWiki\User\User; |
| 10 | |
| 11 | /** |
| 12 | * Hooks from BetaFeatures extension, |
| 13 | * which is optional to use with this extension. |
| 14 | */ |
| 15 | class BetaPreferenceHooks implements GetBetaFeaturePreferencesHook { |
| 16 | |
| 17 | private readonly Config $config; |
| 18 | |
| 19 | public function __construct( |
| 20 | private readonly Config $coreConfig, |
| 21 | ConfigFactory $configFactory |
| 22 | ) { |
| 23 | $this->config = $configFactory->makeConfig( 'visualeditor' ); |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * Handler for the GetBetaFeaturePreferences hook, to add and hide user beta preferences as configured |
| 28 | * |
| 29 | * @param User $user |
| 30 | * @param array &$preferences |
| 31 | */ |
| 32 | public function onGetBetaFeaturePreferences( User $user, array &$preferences ) { |
| 33 | if ( $this->config->get( 'VisualEditorEnableCollabBeta' ) ) { |
| 34 | $iconpath = $this->coreConfig->get( MainConfigNames::ExtensionAssetsPath ) . '/VisualEditor/images'; |
| 35 | |
| 36 | $preferences['visualeditor-collab'] = [ |
| 37 | 'version' => '1.0', |
| 38 | 'label-message' => 'visualeditor-preference-collab-label', |
| 39 | 'desc-message' => 'visualeditor-preference-collab-description', |
| 40 | 'screenshot' => [ |
| 41 | 'ltr' => "$iconpath/betafeatures-icon-collab-ltr.svg", |
| 42 | 'rtl' => "$iconpath/betafeatures-icon-collab-rtl.svg", |
| 43 | ], |
| 44 | 'info-message' => 'visualeditor-preference-collab-info-link', |
| 45 | 'discussion-message' => 'visualeditor-preference-collab-discussion-link', |
| 46 | 'requirements' => [ |
| 47 | 'javascript' => true |
| 48 | ] |
| 49 | ]; |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | } |