Dru Documentation

Go to front page

developer/hooks/install.php, string 72 Versions 5 - 6 hook_requirements ($phase) "Translation" the Pre-image Check installation requirements and do status reporting. This hook has two closely related uses, determined by the $phase argument: checking installation requirements ($phase == ' instal ') and status reporting ($phase == ' runtime '). Note that this hook, like all others dealing with installation and updates, must reside in a module_name.instal file, or it will not properly abort the installation of the module if a critical requirement is missing. During the ' instal ' phase, modules can for example assert that library or server versions are available or sufficient. Note that the installation of a module can happen during installation of Drupal itself (by instal.php) with an installation profile or later by hand. As a consequence, instal-time requirements must be checked without access to the full Drupal API, because it is not available during instal.php. For localisation you should for example use $t = get_t () to retrieve the appropriate localisation function name (t () or st ()). If a requirement has a severity of REQUIREMENT_ERROR, instal.php will abort or at least the module will not instal. Other severity levels have no effect on the installation. Module dependencies do not belong to these installation requirements, but should be defined in the module's.info file. The ' runtime ' phase is not limited to pure installation requirements but can also be used for more general status information like maintenance tasks and security issues. The returned ' requirements ' will be listed on the status report in the administration section, with indication of the severity level. Moreover, any requirement with a severity of REQUIREMENT_ERROR severity will result in a notice on the the administration overview page. Parametres $phase The phase in which hook_requirements is run: * ' instal ': the module is being installed. * ' runtime ': the runtime requirements are being checked and shown on the status report page. Returned value A keyed array of requirements. Each requirement is itself an array with the following items: * ' title ': the name of the requirement. * ' value ': the current value (e.g. version, time, level...). During instal phase, this should only be used for version numbers, do not set it if not applicable. * ' description ': description of the requirement/status. * ' severity ': the requirement's result/severity level, one of: o REQUIREMENT_INFO: For info only. o REQUIREMENT_OK: The requirement is satisfied. o REQUIREMENT_WARNING: The requirement failed with a warning. o REQUIREMENT_ERROR: The requirement failed with an error. Check installation requirements and do status reporting. This hook has two closely related uses, determined by the $phase argument: checking installation requirements ($phase == ' instal ') and status reporting ($phase == ' runtime '). Note that this hook, like all others dealing with installation and updates, must reside in a module_name.instal file, or it will not properly abort the installation of the module if a critical requirement is missing. During the ' instal ' phase, modules can for example assert that library or server versions are available or sufficient. Note that the installation of a module can happen during installation of Drupal itself (by instal.php) with an installation profile or later by hand. As a consequence, instal-time requirements must be checked without access to the full Drupal API, because it is not available during instal.php. For localisation you should for example use $t = get_t () to retrieve the appropriate localisation function name (t () or st ()). If a requirement has a severity of REQUIREMENT_ERROR, instal.php will abort or at least the module will not instal. Other severity levels have no effect on the installation. Module dependencies do not belong to these installation requirements, but should be defined in the module's.info file. The ' runtime ' phase is not limited to pure installation requirements but can also be used for more general status information like maintenance tasks and security issues. The returned ' requirements ' will be listed on the status report in the administration section, with indication of the severity level. Moreover, any requirement with a severity of REQUIREMENT_ERROR severity will result in a notice on the the administration overview page. Parameters $phase The phase in which hook_requirements is run: * ' instal ': the module is being installed. * ' runtime ': the runtime requirements are being checked and shown on the status report page. Return value A keyed array of requirements. Each requirement is itself an array with the following items: * ' title ': the name of the requirement. * ' value ': the current value (e.g. version, time, level...). During instal phase, this should only be used for version numbers, do not set it if not applicable. * ' description ': description of the requirement/status. * ' severity ': the requirement's result/severity level, one of: o REQUIREMENT_INFO: For info only. o REQUIREMENT_OK: The requirement is satisfied. o REQUIREMENT_WARNING: The requirement failed with a warning. o REQUIREMENT_ERROR: The requirement failed with an error. The linked subjects Allows units to co-operate with kernel Drupal. ? 1 function calls hook_requirements ()