| @@ 50-61 (lines=12) @@ | ||
| 47 | * @return ScopedCallback to reset the overridden value | |
| 48 | * @throws MWException | |
| 49 | */ | |
| 50 | 	public static function overrideInstance( PageProps $store = null ) { | |
| 51 | 		if ( !defined( 'MW_PHPUNIT_TEST' ) ) { | |
| 52 | throw new MWException( | |
| 53 | 'Cannot override ' . __CLASS__ . 'default instance in operation.' | |
| 54 | ); | |
| 55 | } | |
| 56 | $previousValue = self::$instance; | |
| 57 | self::$instance = $store; | |
| 58 | 		return new ScopedCallback( function() use ( $previousValue ) { | |
| 59 | self::$instance = $previousValue; | |
| 60 | } ); | |
| 61 | } | |
| 62 | ||
| 63 | /** | |
| 64 | * @return PageProps | |
| @@ 139-151 (lines=13) @@ | ||
| 136 | * @return ScopedCallback to reset the overridden value | |
| 137 | * @throws MWException | |
| 138 | */ | |
| 139 | 	public static function overrideDefaultInstance( WatchedItemStore $store = null ) { | |
| 140 | 		if ( !defined( 'MW_PHPUNIT_TEST' ) ) { | |
| 141 | throw new MWException( | |
| 142 | 'Cannot override ' . __CLASS__ . 'default instance in operation.' | |
| 143 | ); | |
| 144 | } | |
| 145 | ||
| 146 | $previousValue = self::$instance; | |
| 147 | self::$instance = $store; | |
| 148 | 		return new ScopedCallback( function() use ( $previousValue ) { | |
| 149 | self::$instance = $previousValue; | |
| 150 | } ); | |
| 151 | } | |
| 152 | ||
| 153 | /** | |
| 154 | * @return self | |