PHP code example of mwstake / mediawiki-component-inputprocessor

1. Go to this page and download the library: Download mwstake/mediawiki-component-inputprocessor library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mwstake / mediawiki-component-inputprocessor example snippets


$intProcessor = new MWStake\MediaWiki\Component\InputProcessor\IntValue();
$intProcessor
    ->setRequired( true )
    ->setMin( 0 )
    ->setMax( 999 );
    
$processors = [
    'myNumber' => $intProcessor,
    'myNumber2' => $intProcessor
];

$factory = MediaWiki\MediaWikiServices::getInstance()->getService( 'MWStake.InputProcessor.Factory' );
// Either pass configuration directly
$titleProcessor = $factory->createWithData( 'title', [ '= [
       ...
    'myPage' => $titleProcessor,
    ....
];


$processors = [
    'myPage' => [
        'type' => 'title',
        'r' => [
        'type' => 'int',
        '


$factory = MediaWiki\MediaWikiServices::getInstance()->getService( 'MWStake.InputProcessor.Factory' );
$namespaceListProcessor = $factory->create( 'namespace-list' );
$namespaceListProcessor
    ->setRequired( true )
    ->setListSeparator( '|' );

$intProcessor = $factory->create( 'integer' );
$intProcessor
    ->setRequired( true )
    ->setMin( 0 )
    ->setMax( 999 );
    
$processors = [
    'source-namespaces' => $namespaceListProcessor,
    'count' => $intProcessor,
    'label' => [
        'type' => 'string',
        '    foreach ( $errors as $error ) {
        $msg = \Message::newFromKey( $error['message'] )->params( ...$error['params'] );
        $errorText = $msg->plain();
        // Display error
    }
}

// Over config var
$GLOBALS['mwsgInputProcessorRegistry']['my-processor'] = {OF_SPEC};

$GLOBALS['wgHooks']['MWStakeMediaWikiComponentInputProcessorRegisterProcessors'][] = function( &$types ) {
    $types['my-processor'] = {OF_SPEC};
};