mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-11-23 15:16:56 +00:00
Make code using the Math.CheckerFactory service discoverable
Otherwise IDEs and other tools don't know what's going on. ...->getService() returns mixed. Change-Id: If0429485941c19eb0e88896cb1ada66a5320bafe
This commit is contained in:
parent
14647fa3b1
commit
b3e57cbfc2
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace MediaWiki\Extension\Math;
|
||||
|
||||
use MediaWiki\Extension\Math\InputCheck\InputCheckFactory;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
|
@ -24,4 +25,8 @@ final class Math {
|
|||
->get( 'Math.Config' );
|
||||
}
|
||||
|
||||
public static function getCheckerFactory( ContainerInterface $services = null ): InputCheckFactory {
|
||||
return ( $services ?: MediaWikiServices::getInstance() )
|
||||
->get( 'Math.CheckerFactory' );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -689,8 +689,7 @@ abstract class MathRenderer {
|
|||
* @return bool
|
||||
*/
|
||||
protected function doCheck() {
|
||||
$checker = MediaWikiServices::getInstance()
|
||||
->getService( 'Math.CheckerFactory' )
|
||||
$checker = Math::getCheckerFactory()
|
||||
->newDefaultChecker( $this->tex, $this->getInputType(), $this->rbi );
|
||||
|
||||
try {
|
||||
|
|
|
@ -4,7 +4,6 @@ namespace MediaWiki\Extension\Math;
|
|||
|
||||
use DataValues\StringValue;
|
||||
use InvalidArgumentException;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use ValueValidators\Error;
|
||||
use ValueValidators\Result;
|
||||
use ValueValidators\ValueValidator;
|
||||
|
@ -31,8 +30,7 @@ class MathValidator implements ValueValidator {
|
|||
|
||||
// get input String from value
|
||||
$tex = $value->getValue();
|
||||
$checker = MediaWikiServices::getInstance()
|
||||
->getService( 'Math.CheckerFactory' )
|
||||
$checker = Math::getCheckerFactory()
|
||||
->newLocalChecker( $tex, 'tex' );
|
||||
|
||||
if ( $checker->isValid() ) {
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
namespace MediaWiki\Extension\Math\InputCheck;
|
||||
|
||||
use HashBagOStuff;
|
||||
use MediaWiki\Extension\Math\Math;
|
||||
use MediaWiki\Extension\Math\MathMathML;
|
||||
use MediaWiki\Http\HttpRequestFactory;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWikiIntegrationTestCase;
|
||||
use MockHttpTrait;
|
||||
use WANObjectCache;
|
||||
|
@ -130,8 +130,7 @@ class MathoidCheckerTest extends MediaWikiIntegrationTestCase {
|
|||
* @return MathoidChecker
|
||||
*/
|
||||
private function getMathoidChecker( $tex = '\sin x' ): MathoidChecker {
|
||||
return MediaWikiServices::getInstance()
|
||||
->getService( 'Math.CheckerFactory' )
|
||||
return Math::getCheckerFactory()
|
||||
->newMathoidChecker( $tex, 'tex' );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue