Provides validation class to check the plugin ZIP contents Uses fragments of the local_plugins_archive_validator class copyrighted by Marina Glancy that is part of the local_plugins plugin.
Copyright: | 2013, 2015 David Mudrak <david@moodle.com> |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 644 lines (22 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
validator:: (23 methods):
instance()
assert_plugin_type()
assert_moodle_version()
execute()
get_result()
get_messages()
message_level_name()
message_code_name()
message_help_icon()
message_code_info()
get_versionphp_info()
get_language_file_name()
get_rootdir()
__construct()
validate_files_layout()
validate_version_php()
validate_language_pack()
validate_target_location()
parse_version_php()
add_message()
get_stripped_file_contents()
get_plugintype_location()
get_plugin_manager()
instance($zipcontentpath, array $zipcontentfiles) X-Ref |
Factory method returning instance of the validator return: \core\update\validator param: string $zipcontentpath full path to the extracted ZIP contents param: array $zipcontentfiles (string)filerelpath => (bool|string)true or error |
assert_plugin_type($required) X-Ref |
Set the expected plugin type, fail the validation otherwise param: string $required plugin type |
assert_moodle_version($required) X-Ref |
Set the expectation that the plugin can be installed into the given Moodle version param: string $required Moodle version we are about to install to |
execute() X-Ref |
Execute the validation process against all explicit and implicit requirements Returns true if the validation passes (all explicit and implicit requirements pass) and the plugin can be installed. Returns false if the validation fails (some explicit or implicit requirement fails) and the plugin must not be installed. return: bool |
get_result() X-Ref |
Returns overall result of the validation. Null is returned if the validation has not been executed yet. Otherwise this method returns true (the installation can continue) or false (it is not safe to continue with the installation). return: bool|null |
get_messages() X-Ref |
Return the list of validation log messages Each validation message is a plain object with properties level, msgcode and addinfo. return: array of (int)index => (stdClass) validation message |
message_level_name($level) X-Ref |
Returns human readable localised name of the given log level. return: string param: string $level e.g. self::INFO |
message_code_name($msgcode) X-Ref |
If defined, returns human readable validation code. Otherwise, it simply returns the code itself as a fallback. return: string param: string $msgcode |
message_help_icon($msgcode) X-Ref |
Returns help icon for the message code if defined. return: \help_icon|false param: string $msgcode |
message_code_info($msgcode, $addinfo) X-Ref |
Localizes the message additional info if it exists. return: string param: string $msgcode param: array|string|null $addinfo value for the $a placeholder in the string |
get_versionphp_info() X-Ref |
Return the information provided by the the plugin's version.php If version.php was not found in the plugin, null is returned. Otherwise the array is returned. It may be empty if no information was parsed (which should not happen). return: null|array |
get_language_file_name() X-Ref |
Returns the name of the English language file without the .php extension This can be used as a suggestion for fixing the plugin root directory in the ZIP file during the upload. If no file was found, or multiple PHP files are located in lang/en/ folder, then null is returned. return: null|string |
get_rootdir() X-Ref |
Returns the rootdir of the extracted package (after eventual renaming) return: string|null |
__construct($zipcontentpath, array $zipcontentfiles) X-Ref |
No public constructor, use {@link self::instance()} instead. param: string $zipcontentpath full path to the extracted ZIP contents param: array $zipcontentfiles (string)filerelpath => (bool|string)true or error |
validate_files_layout() X-Ref |
Returns false if files in the ZIP do not have required layout. return: bool |
validate_version_php() X-Ref |
Returns false if the version.php file does not declare required information. return: bool |
validate_language_pack() X-Ref |
Returns false if the English language pack is not provided correctly. return: bool |
validate_target_location() X-Ref |
Returns false of the given add-on can't be installed into its location. return: bool |
parse_version_php($fullpath) X-Ref |
Get as much information from existing version.php as possible return: array of found meta-info declarations param: string $fullpath full path to the version.php file |
add_message($level, $msgcode, $a = null) X-Ref |
Append the given message to the messages log param: string $level e.g. self::ERROR param: string $msgcode may form a string param: string|array|object $a optional additional info suitable for {@link get_string()} |
get_stripped_file_contents($fullpath) X-Ref |
Returns bare PHP code from the given file Returns contents without PHP opening and closing tags, text outside php code, comments and extra whitespaces. return: string param: string $fullpath full path to the file |
get_plugintype_location($plugintype) X-Ref |
Returns the full path to the root directory of the given plugin type. return: string|null param: string $plugintype |
get_plugin_manager() X-Ref |
Returns plugin manager to use. return: core_plugin_manager |