MediaWiki  1.29.1
updateCSS.php
Go to the documentation of this file.
1 <?php
25 use Symfony\Component\Process\ProcessBuilder;
26 
27 $IP = getenv( 'MW_INSTALL_PATH' ) ?: __DIR__ . '/../../..';
28 
29 require_once "$IP/maintenance/Maintenance.php";
30 
31 class UpdateCSS extends Maintenance {
32 
33  public function __construct() {
34  parent::__construct();
35  $this->addDescription( 'Generate CSS code for SyntaxHighlight_GeSHi' );
36  }
37 
38  public function execute() {
39  global $wgPygmentizePath;
40 
41  $target = __DIR__ . '/../modules/pygments.generated.css';
42  $css = "/* Stylesheet generated by updateCSS.php */\n";
43 
44  $builder = new ProcessBuilder();
45  $builder->setPrefix( $wgPygmentizePath );
46 
47  $process = $builder
48  ->add( '-f' )->add( 'html' )
49  ->add( '-S' )->add( 'default' )
50  ->add( '-a' )->add( '.' . SyntaxHighlight_GeSHi::HIGHLIGHT_CSS_CLASS )
51  ->getProcess();
52 
53  $process->run();
54 
55  if ( !$process->isSuccessful() ) {
56  throw new \RuntimeException( $process->getErrorOutput() );
57  }
58 
59  $css .= $process->getOutput();
60 
61  if ( file_put_contents( $target, $css ) === false ) {
62  $this->output( "Failed to write to {$target}\n" );
63  } else {
64  $this->output( 'CSS written to ' . realpath( $target ) . "\n" );
65  }
66  }
67 }
68 
69 $maintClass = "UpdateCSS";
70 require_once RUN_MAINTENANCE_IF_MAIN;
Maintenance\addDescription
addDescription( $text)
Set the description text.
Definition: Maintenance.php:287
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
UpdateCSS
Definition: updateCSS.php:31
RUN_MAINTENANCE_IF_MAIN
require_once RUN_MAINTENANCE_IF_MAIN
Definition: maintenance.txt:50
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: maintenance.txt:39
UpdateCSS\__construct
__construct()
Default constructor.
Definition: updateCSS.php:33
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
$css
$css
Definition: styleTest.css.php:50
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
$IP
$IP
Definition: updateCSS.php:27
UpdateCSS\execute
execute()
Do the actual work.
Definition: updateCSS.php:38
$maintClass
$maintClass
Definition: updateCSS.php:69
Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition: Maintenance.php:373