Validates the contents of extracted plugin ZIP file.
More...
|
| assert_moodle_version ($required) |
| Set the expectation that the plugin can be installed into the given Moodle version.
|
|
| assert_plugin_type ($required) |
| Set the expected plugin type, fail the validation otherwise.
|
|
| execute () |
| Execute the validation process against all explicit and implicit requirements.
|
|
| get_language_file_name () |
| Returns the name of the English language file without the .php extension.
|
|
| get_messages () |
| Return the list of validation log messages.
|
|
| get_plugintype_location ($plugintype) |
| Returns the full path to the root directory of the given plugin type.
|
|
| get_result () |
| Returns overall result of the validation.
|
|
| get_rootdir () |
| Returns the rootdir of the extracted package (after eventual renaming)
|
|
| get_versionphp_info () |
| Return the information provided by the the plugin's version.php.
|
|
| message_code_info ($msgcode, $addinfo) |
| Localizes the message additional info if it exists.
|
|
| message_code_name ($msgcode) |
| If defined, returns human readable validation code.
|
|
| message_help_icon ($msgcode) |
| Returns help icon for the message code if defined.
|
|
| message_level_name ($level) |
| Returns human readable localised name of the given log level.
|
|
| validate_target_location () |
| Returns false of the given add-on can't be installed into its location.
|
|
|
static | instance ($zipcontentpath, array $zipcontentfiles) |
| Factory method returning instance of the validator.
|
|
|
const | DEBUG = 'debug' |
| Debugging message level, should be displayed in debugging mode only.
|
|
const | ERROR = 'error' |
| Critical error message level, causes the validation fail.
|
|
const | INFO = 'info' |
| Information message level that the admin should be aware of.
|
|
const | WARNING = 'warning' |
| Warning message level, validation does not fail but the admin should be always informed.
|
|
|
array | $assertions = null |
| explicit list of expected/required characteristics of the ZIP
|
|
string | $extractdir = null |
| full path to the extracted ZIP contents
|
|
array | $extractfiles = null |
| as returned by zip_packer::extract_to_pathname()
|
|
string null | $langfilename = null |
| the name of found English language file without the .php extension
|
|
array | $messages = array() |
| of validation log messages
|
|
bool | $result = null |
| overall result of validation
|
|
string | $rootdir = null |
| the name of the plugin root directory
|
|
array null | $versionphp = null |
| array of relevant data obtained from version.php
|
|
Validates the contents of extracted plugin ZIP file.
- Copyright
- 2013, 2015 David Mudrak david.nosp@m.@moo.nosp@m.dle.c.nosp@m.om
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
◆ __construct()
core\update\validator::__construct |
( |
| $zipcontentpath, |
|
|
array | $zipcontentfiles ) |
|
protected |
No public constructor, use self::instance() instead.
- Parameters
-
string | $zipcontentpath | full path to the extracted ZIP contents |
array | $zipcontentfiles | (string)filerelpath => (bool|string)true or error |
◆ add_message()
core\update\validator::add_message |
( |
| $level, |
|
|
| $msgcode, |
|
|
| $a = null ) |
|
protected |
Append the given message to the messages log.
- Parameters
-
string | $level | e.g. self\ERROR |
string | $msgcode | may form a string |
string | array | object | $a | optional additional info suitable for get_string() |
◆ assert_moodle_version()
core\update\validator::assert_moodle_version |
( |
| $required | ) |
|
Set the expectation that the plugin can be installed into the given Moodle version.
- Parameters
-
string | $required | Moodle version we are about to install to |
◆ assert_plugin_type()
core\update\validator::assert_plugin_type |
( |
| $required | ) |
|
Set the expected plugin type, fail the validation otherwise.
- Parameters
-
string | $required | plugin type |
◆ execute()
core\update\validator::execute |
( |
| ) |
|
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 values
-
◆ get_language_file_name()
core\update\validator::get_language_file_name |
( |
| ) |
|
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 values
-
◆ get_messages()
core\update\validator::get_messages |
( |
| ) |
|
Return the list of validation log messages.
Each validation message is a plain object with properties level, msgcode and addinfo.
- Return values
-
array | of (int)index => (stdClass) validation message |
◆ get_plugin_manager()
core\update\validator::get_plugin_manager |
( |
| ) |
|
|
protected |
Returns plugin manager to use.
- Return values
-
◆ get_plugintype_location()
core\update\validator::get_plugintype_location |
( |
| $plugintype | ) |
|
Returns the full path to the root directory of the given plugin type.
- Parameters
-
- Return values
-
◆ get_result()
core\update\validator::get_result |
( |
| ) |
|
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 values
-
◆ get_rootdir()
core\update\validator::get_rootdir |
( |
| ) |
|
Returns the rootdir of the extracted package (after eventual renaming)
- Return values
-
◆ get_stripped_file_contents()
core\update\validator::get_stripped_file_contents |
( |
| $fullpath | ) |
|
|
protected |
Returns bare PHP code from the given file.
Returns contents without PHP opening and closing tags, text outside php code, comments and extra whitespaces.
- Parameters
-
string | $fullpath | full path to the file |
- Return values
-
◆ get_versionphp_info()
core\update\validator::get_versionphp_info |
( |
| ) |
|
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 values
-
◆ instance()
static core\update\validator::instance |
( |
| $zipcontentpath, |
|
|
array | $zipcontentfiles ) |
|
static |
Factory method returning instance of the validator.
- Parameters
-
string | $zipcontentpath | full path to the extracted ZIP contents |
array | $zipcontentfiles | (string)filerelpath => (bool|string)true or error |
- Return values
-
◆ message_code_info()
core\update\validator::message_code_info |
( |
| $msgcode, |
|
|
| $addinfo ) |
Localizes the message additional info if it exists.
- Parameters
-
string | $msgcode | |
array | string | null | $addinfo | value for the $a placeholder in the string |
- Return values
-
◆ message_code_name()
core\update\validator::message_code_name |
( |
| $msgcode | ) |
|
If defined, returns human readable validation code.
Otherwise, it simply returns the code itself as a fallback.
- Parameters
-
- Return values
-
◆ message_help_icon()
core\update\validator::message_help_icon |
( |
| $msgcode | ) |
|
Returns help icon for the message code if defined.
- Parameters
-
- Return values
-
◆ message_level_name()
core\update\validator::message_level_name |
( |
| $level | ) |
|
Returns human readable localised name of the given log level.
- Parameters
-
string | $level | e.g. self\INFO |
- Return values
-
◆ parse_version_php()
core\update\validator::parse_version_php |
( |
| $fullpath | ) |
|
|
protected |
Get as much information from existing version.php as possible.
- Parameters
-
string | $fullpath | full path to the version.php file |
- Return values
-
array | of found meta-info declarations |
◆ validate_files_layout()
core\update\validator::validate_files_layout |
( |
| ) |
|
|
protected |
Returns false if files in the ZIP do not have required layout.
- Return values
-
◆ validate_language_pack()
core\update\validator::validate_language_pack |
( |
| ) |
|
|
protected |
Returns false if the English language pack is not provided correctly.
- Return values
-
◆ validate_target_location()
core\update\validator::validate_target_location |
( |
| ) |
|
Returns false of the given add-on can't be installed into its location.
- Return values
-
◆ validate_version_php()
core\update\validator::validate_version_php |
( |
| ) |
|
|
protected |
Returns false if the version.php file does not declare required information.
- Return values
-
The documentation for this class was generated from the following file:
- lib/classes/update/validator.php