MediaWiki master
FeatureShutdown.php
Go to the documentation of this file.
1<?php
7namespace MediaWiki;
8
10
19 public const CONSTRUCTOR_OPTIONS = [
20 'FeatureShutdown',
21 ];
22
24 private $shutdowns;
25
29 public function __construct( ServiceOptions $options ) {
30 $options->assertRequiredOptions( self::CONSTRUCTOR_OPTIONS );
31 $this->shutdowns = $options->get( 'FeatureShutdown' );
32 }
33
38 public function findForFeature( string $featureName ): ?array {
39 if ( !isset( $this->shutdowns[$featureName] ) ) {
40 return null;
41 }
42
43 $time = time();
44 foreach ( $this->shutdowns[$featureName] as $shutdown ) {
45 if ( strtotime( $shutdown['start'] ) > $time || strtotime( $shutdown['end'] ) < $time ) {
46 continue;
47 }
48
49 if ( isset( $shutdown['percentage'] ) && rand( 0, 99 ) > $shutdown['percentage'] ) {
50 continue;
51 }
52
53 return $shutdown;
54 }
55
56 return null;
57 }
58}
if(!defined('MW_SETUP_CALLBACK'))
Definition WebStart.php:68
A class for passing options to services.
assertRequiredOptions(array $expectedKeys)
Assert that the list of options provided in this instance exactly match $expectedKeys,...
Helper to check if certain features should be temporarily disabled.
findForFeature(string $featureName)
__construct(ServiceOptions $options)
Helper trait for implementations \DAO.