MediaWiki  master
validateRegistrationFile.php
Go to the documentation of this file.
1 <?php
2 
3 require_once __DIR__ . '/Maintenance.php';
4 
6  public function __construct() {
7  parent::__construct();
8  $this->addArg(
9  'path',
10  'Path or glob pattern to extension.json/skin.json file.',
11  true
12  );
13  }
14 
15  public function execute() {
16  $validator = new ExtensionJsonValidator( function ( $msg ) {
17  $this->fatalError( $msg );
18  } );
19  $validator->checkDependencies();
20  $paths = glob( $this->getArg( 0 ) );
21  foreach ( $paths as $path ) {
22  try {
23  $validator->validate( $path );
24  $this->output( "$path validates against the schema!\n" );
25  } catch ( ExtensionJsonValidationError $e ) {
26  $this->fatalError( $e->getMessage() );
27  }
28  }
29  }
30 }
31 
32 $maintClass = ValidateRegistrationFile::class;
33 require_once RUN_MAINTENANCE_IF_MAIN;
ValidateRegistrationFile\execute
execute()
Do the actual work.
Definition: validateRegistrationFile.php:15
RUN_MAINTENANCE_IF_MAIN
const RUN_MAINTENANCE_IF_MAIN
Definition: Maintenance.php:38
ValidateRegistrationFile\__construct
__construct()
Default constructor.
Definition: validateRegistrationFile.php:6
$maintClass
$maintClass
Definition: validateRegistrationFile.php:32
Maintenance\fatalError
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
Definition: Maintenance.php:486
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: Maintenance.php:55
ExtensionJsonValidator\checkDependencies
checkDependencies()
Definition: ExtensionJsonValidator.php:57
ValidateRegistrationFile
Definition: validateRegistrationFile.php:5
ExtensionJsonValidator
Validate extension.json files against their JSON schema.
Definition: ExtensionJsonValidator.php:39
Maintenance\addArg
addArg( $arg, $description, $required=true)
Add some args that are needed.
Definition: Maintenance.php:298
$path
$path
Definition: NoLocalSettings.php:25
ExtensionJsonValidationError
@newable
Definition: ExtensionJsonValidationError.php:25
Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition: Maintenance.php:433
Maintenance\getArg
getArg( $argId=0, $default=null)
Get an argument.
Definition: Maintenance.php:351