Moodle deployment utility
Copyright: | 2012 David Mudrak <david@moodle.com> |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
Version: | 1.1 |
File Size: | 1574 lines (53 kb) |
Included or required: | 1 time |
Referenced: | 0 times |
Includes or requires: | 0 files |
invalid_coding_exception:: (0 methods):
missing_option_exception:: (0 methods):
invalid_option_exception:: (0 methods):
unauthorized_access_exception:: (0 methods):
download_file_exception:: (0 methods):
backup_folder_exception:: (0 methods):
zip_exception:: (0 methods):
filesystem_exception:: (0 methods):
checksum_exception:: (0 methods):
invalid_setting_exception:: (4 methods):
instance()
initialize()
__construct()
__clone()
input_manager:: (11 methods):
get_option()
get_option_info()
cast_value()
initialize()
validate_option_name()
get_required_option()
get_optional_option()
get_option()
has_option()
initialize()
populate_options()
input_cli_provider:: (1 method):
parse_raw_options()
input_http_provider:: (1 method):
parse_raw_options()
output_manager:: (2 methods):
__call()
initialize()
output_cli_provider:: (2 methods):
help()
outln()
output_http_provider:: (4 methods):
help()
exception()
start_output()
end_output()
worker:: (21 methods):
execute()
log_exception()
initialize()
done()
authorize()
log_location()
target_location()
backup_location()
download_file()
get_env()
get_cacert()
log()
format_log_message()
move_directory_source_precheck()
move_directory_target_precheck()
create_directory_precheck()
move_directory()
move_directory_into()
remove_directory()
unzip_plugin()
redirect()
exception_handlers:: (4 methods):
set_handler()
format_exception_info()
bootstrap_exception_handler()
default_exception_handler()
Class: invalid_coding_exception - X-Ref
Class: missing_option_exception - X-Ref
Class: invalid_option_exception - X-Ref
Class: unauthorized_access_exception - X-Ref
Class: download_file_exception - X-Ref
Class: backup_folder_exception - X-Ref
Class: zip_exception - X-Ref
Class: filesystem_exception - X-Ref
Class: checksum_exception - X-Ref
Class: invalid_setting_exception - X-Ref
instance() X-Ref |
Factory method returning the singleton instance. Subclasses may want to override the {@link self::initialize()} method that is called right after their instantiation. return: mixed the singleton instance |
initialize() X-Ref |
Optional post-instantiation code. |
__construct() X-Ref |
Direct instantiation not allowed, use the factory method {@link instance()} |
__clone() X-Ref |
Sorry, this is singleton. |
Class: input_manager - X-Ref
Provides access to the script options.get_option($name, $default = 'provide_default_value_explicitly') X-Ref |
Returns the value of an option passed to the script. If the caller passes just the $name, the requested argument is considered required. The caller may specify the second argument which then makes the argument optional with the given default value. If the type of the $name option is TYPE_FLAG (switch), this method returns true if the flag has been passed or false if it was not. Specifying the default value makes no sense in this case and leads to invalid coding exception. The array options are not supported. param: string $name return: mixed |
get_option_info($name=null) X-Ref |
Returns the meta-information about the given option. param: string|null $name short or long option name, defaults to returning the list of all return: array|object|false array with all, object with the specific option meta-information or false of no such an option |
cast_value($raw, $type) X-Ref |
Casts the value to the given type. param: mixed $raw the raw value param: string $type the expected value type, e.g. {@link input_manager::TYPE_INT} return: mixed |
initialize() X-Ref |
Picks the appropriate helper class to delegate calls to. |
validate_option_name($name) X-Ref |
Validates the parameter name. param: string $name |
get_required_option($name) X-Ref |
Returns cleaned option value or throws exception. param: string $name the name of the parameter param: string $type the parameter type, e.g. {@link input_manager::TYPE_INT} return: mixed |
get_optional_option($name, $default) X-Ref |
Returns cleaned option value or the default value param: string $name the name of the parameter param: string $type the parameter type, e.g. {@link input_manager::TYPE_INT} param: mixed $default the default value. return: mixed |
get_option($name) X-Ref |
Returns the casted value of the option. param: string $name option name return: mixed casted value of the option |
has_option($name) X-Ref |
Was the given option passed? param: string $name optionname return: bool |
initialize() X-Ref |
Initializes the input provider. |
populate_options() X-Ref |
Parses and validates all supported options passed to the script. |
Class: input_cli_provider - X-Ref
Provides access to the script options passed via CLI.parse_raw_options() X-Ref |
Parses raw options passed to the script. return: array as returned by getopt() |
Class: input_http_provider - X-Ref
Provides access to the script options passed via HTTP request.parse_raw_options() X-Ref |
Parses raw options passed to the script. return: array of raw values passed via HTTP request |
Class: output_manager - X-Ref
Provides output operations.__call($name, array $arguments = array() X-Ref |
Magic method triggered when invoking an inaccessible method. param: string $name method name param: array $arguments method arguments |
initialize() X-Ref |
Picks the appropriate helper class to delegate calls to. |
Class: output_http_provider - X-Ref
Provides HTML output as a part of HTTP response.help() X-Ref |
Prints help on the script usage. |
exception(Exception $e) X-Ref |
Display the information about uncaught exception param: Exception $e uncaught exception |
start_output() X-Ref |
Produce the HTML page header |
end_output() X-Ref |
Produce the HTML page footer |
execute() X-Ref |
Main - the one that actually does something |
log_exception(Exception $e) X-Ref |
Attempts to log a thrown exception param: Exception $e uncaught exception |
initialize() X-Ref |
Initialize the worker class. |
done($exitcode = self::EXIT_OK) X-Ref |
Finish this script execution. param: int $exitcode |
authorize() X-Ref |
Authorize access to the script. In CLI mode, the access is automatically authorized. In HTTP mode, the passphrase submitted via the request params must match the contents of the file, the name of which is passed in another parameter. |
log_location() X-Ref |
Returns the full path to the log file. return: string |
target_location($source) X-Ref |
Choose the target location for the given ZIP's URL. param: string $source URL return: string |
backup_location($path) X-Ref |
Choose the location of the current plugin folder backup param: string $path full path to the current folder return: string |
download_file($source, $target) X-Ref |
Downloads the given file into the given destination. This is basically a simplified version of {@link download_file_content()} from Moodle itself, tuned for fetching files from moodle.org servers. param: string $source file url starting with http(s):// param: string $target store the downloaded content to this file (full path) return: bool true on success, false otherwise |
get_env($key) X-Ref |
Fetch environment settings. param: string $key The key to fetch return: mixed The value of the key if found. |
get_cacert() X-Ref |
Get the location of ca certificates. return: string absolute file path or empty if default used |
log($message) X-Ref |
Log a message param: string $message |
format_log_message($msg) X-Ref |
Prepares the log message for writing into the file param: string $msg return: string |
move_directory_source_precheck($source) X-Ref |
Checks to see if the given source could be safely moved into a new location param: string $source full path to the existing directory return: bool |
move_directory_target_precheck($target) X-Ref |
Checks to see if a source folder could be safely moved into the given new location param: string $destination full path to the new expected location of a folder return: bool |
create_directory_precheck($path) X-Ref |
Make sure the given directory can be created (and removed) param: string $path full path to the folder return: bool |
move_directory($source, $target, $keepsourceroot = false) X-Ref |
Moves the given source into a new location recursively The target location can not exist. param: string $source full path to the existing directory param: string $destination full path to the new location of the folder param: bool $keepsourceroot should the root of the $source be kept or removed at the end return: bool |
move_directory_into($source, $target, $keepsourceroot = false) X-Ref |
Moves the given source into a new location recursively If the target already exists, files are moved into it. The target is created otherwise. param: string $source full path to the existing directory param: string $destination full path to the new location of the folder param: bool $keepsourceroot should the root of the $source be kept or removed at the end return: bool |
remove_directory($path, $keeppathroot = false) X-Ref |
Deletes the given directory recursively param: string $path full path to the directory param: bool $keeppathroot should the root of the $path be kept (i.e. remove the content only) or removed too return: bool |
unzip_plugin($ziplocation, $plugintyperoot, $expectedlocation, $backuplocation) X-Ref |
Unzip the file obtained from the Plugins directory to this site param: string $ziplocation full path to the ZIP file param: string $plugintyperoot full path to the plugin's type location param: string $expectedlocation expected full path to the plugin after it is extracted param: string|bool $backuplocation location of the previous version of the plugin or false for no backup |
redirect($url) X-Ref |
Redirect the browser param: string $url |
Class: exception_handlers - X-Ref
Provides exception handlers for this scriptset_handler($handler) X-Ref |
Sets the exception handler param: string $handler name |
format_exception_info(Exception $e) X-Ref |
Returns the text describing the thrown exception By default, PHP displays full path to scripts when the exception is thrown. In order to prevent sensitive information leak (and yes, the path to scripts at a web server _is_ sensitive information) the path to scripts is removed from the message. param: Exception $e thrown exception return: string |
bootstrap_exception_handler(Exception $e) X-Ref |
Very basic exception handler param: Exception $e uncaught exception |
default_exception_handler(Exception $e) X-Ref |
Default exception handler When this handler is used, input_manager and output_manager singleton instances already exist in the memory and can be used. param: Exception $e uncaught exception |