mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-12-18 02:20:46 +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;
|
namespace MediaWiki\Extension\Math;
|
||||||
|
|
||||||
|
use MediaWiki\Extension\Math\InputCheck\InputCheckFactory;
|
||||||
use MediaWiki\MediaWikiServices;
|
use MediaWiki\MediaWikiServices;
|
||||||
use Psr\Container\ContainerInterface;
|
use Psr\Container\ContainerInterface;
|
||||||
|
|
||||||
|
@ -24,4 +25,8 @@ final class Math {
|
||||||
->get( 'Math.Config' );
|
->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
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function doCheck() {
|
protected function doCheck() {
|
||||||
$checker = MediaWikiServices::getInstance()
|
$checker = Math::getCheckerFactory()
|
||||||
->getService( 'Math.CheckerFactory' )
|
|
||||||
->newDefaultChecker( $this->tex, $this->getInputType(), $this->rbi );
|
->newDefaultChecker( $this->tex, $this->getInputType(), $this->rbi );
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -4,7 +4,6 @@ namespace MediaWiki\Extension\Math;
|
||||||
|
|
||||||
use DataValues\StringValue;
|
use DataValues\StringValue;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use MediaWiki\MediaWikiServices;
|
|
||||||
use ValueValidators\Error;
|
use ValueValidators\Error;
|
||||||
use ValueValidators\Result;
|
use ValueValidators\Result;
|
||||||
use ValueValidators\ValueValidator;
|
use ValueValidators\ValueValidator;
|
||||||
|
@ -31,8 +30,7 @@ class MathValidator implements ValueValidator {
|
||||||
|
|
||||||
// get input String from value
|
// get input String from value
|
||||||
$tex = $value->getValue();
|
$tex = $value->getValue();
|
||||||
$checker = MediaWikiServices::getInstance()
|
$checker = Math::getCheckerFactory()
|
||||||
->getService( 'Math.CheckerFactory' )
|
|
||||||
->newLocalChecker( $tex, 'tex' );
|
->newLocalChecker( $tex, 'tex' );
|
||||||
|
|
||||||
if ( $checker->isValid() ) {
|
if ( $checker->isValid() ) {
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
namespace MediaWiki\Extension\Math\InputCheck;
|
namespace MediaWiki\Extension\Math\InputCheck;
|
||||||
|
|
||||||
use HashBagOStuff;
|
use HashBagOStuff;
|
||||||
|
use MediaWiki\Extension\Math\Math;
|
||||||
use MediaWiki\Extension\Math\MathMathML;
|
use MediaWiki\Extension\Math\MathMathML;
|
||||||
use MediaWiki\Http\HttpRequestFactory;
|
use MediaWiki\Http\HttpRequestFactory;
|
||||||
use MediaWiki\MediaWikiServices;
|
|
||||||
use MediaWikiIntegrationTestCase;
|
use MediaWikiIntegrationTestCase;
|
||||||
use MockHttpTrait;
|
use MockHttpTrait;
|
||||||
use WANObjectCache;
|
use WANObjectCache;
|
||||||
|
@ -130,8 +130,7 @@ class MathoidCheckerTest extends MediaWikiIntegrationTestCase {
|
||||||
* @return MathoidChecker
|
* @return MathoidChecker
|
||||||
*/
|
*/
|
||||||
private function getMathoidChecker( $tex = '\sin x' ): MathoidChecker {
|
private function getMathoidChecker( $tex = '\sin x' ): MathoidChecker {
|
||||||
return MediaWikiServices::getInstance()
|
return Math::getCheckerFactory()
|
||||||
->getService( 'Math.CheckerFactory' )
|
|
||||||
->newMathoidChecker( $tex, 'tex' );
|
->newMathoidChecker( $tex, 'tex' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue