addDescription( <<addArg( 'action', 'One of "update", "verify", "make-sri" or "make-cdx"', true ); $this->addArg( 'module', 'Name of a single module (Default: all)', false ); $this->addOption( 'extension', 'Manage foreign resources for the given extension, instead of core', false, true ); $this->addOption( 'skin', 'Manage foreign resources for the given skin, instead of core', false, true ); $this->addOption( 'verbose', 'Be verbose', false, false, 'v' ); } /** * @return bool */ public function execute() { global $IP; $component = $this->getOption( 'extension' ) ?? $this->getOption( 'skin' ) ?? '#core'; $foreignResourcesDirs = ExtensionRegistry::getInstance()->getAttribute( 'ForeignResourcesDir' ) + [ '#core' => "{$IP}/resources/lib" ]; if ( !array_key_exists( $component, $foreignResourcesDirs ) ) { $this->fatalError( "Unknown component: $component\n" ); } $foreignResourcesFile = "{$foreignResourcesDirs[$component]}/foreign-resources.yaml"; $frm = new ForeignResourceManager( $foreignResourcesFile, dirname( $foreignResourcesFile ), function ( $text ) { $this->output( $text ); }, function ( $text ) { $this->error( $text ); }, function ( $text ) { if ( $this->hasOption( 'verbose' ) ) { $this->output( $text ); } } ); $action = $this->getArg( 0 ); $module = $this->getArg( 1, 'all' ); try { return $frm->run( $action, $module ); } catch ( Exception $e ) { $this->fatalError( "Error: {$e->getMessage()}" ); } } } // @codeCoverageIgnoreStart $maintClass = ManageForeignResources::class; require_once RUN_MAINTENANCE_IF_MAIN; // @codeCoverageIgnoreEnd