Mercurial > hg > cmmr2012-drupal-site
comparison core/lib/Drupal/Core/Extension/module.api.php @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | a9cd425dd02b |
children |
comparison
equal
deleted
inserted
replaced
4:a9cd425dd02b | 5:12f9dff5fda9 |
---|---|
4 * @file | 4 * @file |
5 * Hooks related to module and update systems. | 5 * Hooks related to module and update systems. |
6 */ | 6 */ |
7 | 7 |
8 use Drupal\Core\Database\Database; | 8 use Drupal\Core\Database\Database; |
9 use Drupal\Core\File\FileSystemInterface; | |
9 use Drupal\Core\Url; | 10 use Drupal\Core\Url; |
10 use Drupal\Core\Utility\UpdateException; | 11 use Drupal\Core\Utility\UpdateException; |
11 | 12 |
12 /** | 13 /** |
13 * @defgroup update_api Update API | 14 * @defgroup update_api Update API |
77 * An associative array whose keys are hook names and whose values are an | 78 * An associative array whose keys are hook names and whose values are an |
78 * associative array containing: | 79 * associative array containing: |
79 * - group: A string defining the group to which the hook belongs. The module | 80 * - group: A string defining the group to which the hook belongs. The module |
80 * system will determine whether a file with the name $module.$group.inc | 81 * system will determine whether a file with the name $module.$group.inc |
81 * exists, and automatically load it when required. | 82 * exists, and automatically load it when required. |
82 * | |
83 * @see hook_hook_info_alter() | |
84 */ | 83 */ |
85 function hook_hook_info() { | 84 function hook_hook_info() { |
86 $hooks['token_info'] = [ | 85 $hooks['token_info'] = [ |
87 'group' => 'tokens', | 86 'group' => 'tokens', |
88 ]; | 87 ]; |
129 } | 128 } |
130 | 129 |
131 /** | 130 /** |
132 * Alter the information parsed from module and theme .info.yml files. | 131 * Alter the information parsed from module and theme .info.yml files. |
133 * | 132 * |
134 * This hook is invoked in _system_rebuild_module_data() and in | 133 * This hook is invoked in \Drupal\Core\Extension\ExtensionList::doList(). A |
135 * \Drupal\Core\Extension\ThemeHandlerInterface::rebuildThemeData(). A module | 134 * module may implement this hook in order to add to or alter the data generated |
136 * may implement this hook in order to add to or alter the data generated by | 135 * by reading the .info.yml file with \Drupal\Core\Extension\InfoParser. |
137 * reading the .info.yml file with \Drupal\Core\Extension\InfoParser. | |
138 * | 136 * |
139 * Using implementations of this hook to make modules required by setting the | 137 * Using implementations of this hook to make modules required by setting the |
140 * $info['required'] key is discouraged. Doing so will slow down the module | 138 * $info['required'] key is discouraged. Doing so will slow down the module |
141 * installation and uninstallation process. Instead, use | 139 * installation and uninstallation process. Instead, use |
142 * \Drupal\Core\Extension\ModuleUninstallValidatorInterface. | 140 * \Drupal\Core\Extension\ModuleUninstallValidatorInterface. |
227 * @see hook_modules_installed() | 225 * @see hook_modules_installed() |
228 */ | 226 */ |
229 function hook_install() { | 227 function hook_install() { |
230 // Create the styles directory and ensure it's writable. | 228 // Create the styles directory and ensure it's writable. |
231 $directory = file_default_scheme() . '://styles'; | 229 $directory = file_default_scheme() . '://styles'; |
232 file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS); | 230 \Drupal::service('file_system')->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS); |
233 } | 231 } |
234 | 232 |
235 /** | 233 /** |
236 * Perform necessary actions before a module is uninstalled. | 234 * Perform necessary actions before a module is uninstalled. |
237 * | 235 * |
283 * @see hook_schema() | 281 * @see hook_schema() |
284 * @see hook_modules_uninstalled() | 282 * @see hook_modules_uninstalled() |
285 */ | 283 */ |
286 function hook_uninstall() { | 284 function hook_uninstall() { |
287 // Remove the styles directory and generated images. | 285 // Remove the styles directory and generated images. |
288 file_unmanaged_delete_recursive(file_default_scheme() . '://styles'); | 286 \Drupal::service('file_system')->deleteRecursive(file_default_scheme() . '://styles'); |
289 } | 287 } |
290 | 288 |
291 /** | 289 /** |
292 * Return an array of tasks to be performed by an installation profile. | 290 * Return an array of tasks to be performed by an installation profile. |
293 * | 291 * |
974 'severity' => REQUIREMENT_ERROR, | 972 'severity' => REQUIREMENT_ERROR, |
975 'value' => t('Never run'), | 973 'value' => t('Never run'), |
976 ]; | 974 ]; |
977 } | 975 } |
978 | 976 |
979 $requirements['cron']['description'] .= ' ' . t('You can <a href=":cron">run cron manually</a>.', [':cron' => \Drupal::url('system.run_cron')]); | 977 $requirements['cron']['description'] .= ' ' . t('You can <a href=":cron">run cron manually</a>.', [':cron' => Url::fromRoute('system.run_cron')->toString()]); |
980 | 978 |
981 $requirements['cron']['title'] = t('Cron maintenance tasks'); | 979 $requirements['cron']['title'] = t('Cron maintenance tasks'); |
982 } | 980 } |
983 | 981 |
984 return $requirements; | 982 return $requirements; |