Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
tool_uploaduser\cli_helper Class Reference

Helper method for CLI script to upload users (also has special wrappers for cli* functions for phpunit testing) More...

Public Member Functions

 __construct (?string $progresstrackerclass=null)
 cli_helper constructor.
 
 get_cli_option (string $key)
 Get CLI option.
 
 get_stats ()
 Get process statistics.
 
 print_help ()
 Print help for export.
 
 process ()
 Process the upload.
 

Protected Member Functions

 cli_error ($text, $errorcode=1)
 Write to standard error output and exit with the given code.
 
 cli_problem ($text)
 Write error notification.
 
 cli_write ($text)
 Write a text to the given stream.
 
 cli_writeln ($text)
 Write a text followed by an end of line symbol to the given stream.
 
 convert_to_table (array $column1, array $column2, int $indent=0)
 Display as CLI table.
 
 die ($errorcode)
 Wrapper for "die()" method so we can unittest it.
 
 mock_form (array $customdata, array $submitteddata)
 Mock form submission.
 
 options_definitions ()
 Options used in this CLI script.
 
 prepare_form_elements_for_cli (array $elements, array $defaults)
 Prepare form elements for CLI.
 
 print_help_options (array $options)
 Display available CLI options as a table.
 

Protected Attributes

array $clioptions
 
string $operation
 
process $process
 
string $progresstrackerclass
 
array $unrecognized
 

Detailed Description

Helper method for CLI script to upload users (also has special wrappers for cli* functions for phpunit testing)

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

tool_uploaduser\cli_helper::__construct ( ?string $progresstrackerclass = null)

cli_helper constructor.

Parameters
string | null$progresstrackerclass

Member Function Documentation

◆ cli_error()

tool_uploaduser\cli_helper::cli_error ( $text,
$errorcode = 1 )
protected

Write to standard error output and exit with the given code.

Parameters
string$text
int$errorcode
Return values
void(does not return)

◆ cli_problem()

tool_uploaduser\cli_helper::cli_problem ( $text)
protected

Write error notification.

Parameters
string$text
Return values
void

◆ cli_write()

tool_uploaduser\cli_helper::cli_write ( $text)
protected

Write a text to the given stream.

Parameters
string$texttext to be written

◆ cli_writeln()

tool_uploaduser\cli_helper::cli_writeln ( $text)
protected

Write a text followed by an end of line symbol to the given stream.

Parameters
string$texttext to be written

◆ convert_to_table()

tool_uploaduser\cli_helper::convert_to_table ( array $column1,
array $column2,
int $indent = 0 )
protected

Display as CLI table.

Parameters
array$column1
array$column2
int$indent
Return values
string

◆ die()

tool_uploaduser\cli_helper::die ( $errorcode)
protected

Wrapper for "die()" method so we can unittest it.

Parameters
mixed$errorcode
Exceptions
moodle_exception

◆ get_cli_option()

tool_uploaduser\cli_helper::get_cli_option ( string $key)

Get CLI option.

Parameters
string$key
Return values
mixed|null

◆ get_stats()

tool_uploaduser\cli_helper::get_stats ( )

Get process statistics.

Return values
array

◆ mock_form()

tool_uploaduser\cli_helper::mock_form ( array $customdata,
array $submitteddata )
protected

Mock form submission.

Parameters
array$customdata
array$submitteddata
Return values
admin_uploaduser_form2

◆ options_definitions()

tool_uploaduser\cli_helper::options_definitions ( )
protected

Options used in this CLI script.

Return values
array

◆ prepare_form_elements_for_cli()

tool_uploaduser\cli_helper::prepare_form_elements_for_cli ( array $elements,
array $defaults )
protected

Prepare form elements for CLI.

Parameters
HTML_QuickForm_element[]$elements
array$defaults
Return values
array

◆ print_help_options()

tool_uploaduser\cli_helper::print_help_options ( array $options)
protected

Display available CLI options as a table.

Parameters
array$options

The documentation for this class was generated from the following file: