WP_CLI\Bootstrap
LoadRequiredCommand::process
Process this single bootstrapping step.
Method of the class: LoadRequiredCommand{}
No Hooks.
Returns
BootstrapState. Modified state to pass to the next step.
Usage
$LoadRequiredCommand = new LoadRequiredCommand(); $LoadRequiredCommand->process( $state );
- $state(BootstrapState) (required)
- Contextual state to pass into the step.
LoadRequiredCommand::process() LoadRequiredCommand::process code WP-CLI 2.13.0-alpha
public function process( BootstrapState $state ) {
if ( $state->getValue( BootstrapState::IS_PROTECTED_COMMAND, false ) ) {
return $state;
}
$runner = new RunnerInstance();
if ( ! isset( $runner()->config['require'] ) ) {
return $state;
}
foreach ( $runner()->config['require'] as $path ) {
if ( ! file_exists( $path ) ) {
$context = '';
$required_files = $runner()->get_required_files();
foreach ( [ 'global', 'project', 'runtime' ] as $scope ) {
if ( in_array( $path, $required_files[ $scope ], true ) ) {
switch ( $scope ) {
case 'global':
$context = ' (from global ' . Utils\basename( $runner()->get_global_config_path() ) . ')';
break;
case 'project':
$context = ' (from project\'s ' . Utils\basename( $runner()->get_project_config_path() ) . ')';
break;
case 'runtime':
$context = ' (from runtime argument)';
break;
}
break;
}
}
WP_CLI::error( sprintf( "Required file '%s' doesn't exist%s.", Utils\basename( $path ), $context ) );
}
Utils\load_file( $path );
WP_CLI::debug( 'Required file from config: ' . $path, 'bootstrap' );
}
return $state;
}