From 89580246ee27d13c943172e4956fa266bcf8754a Mon Sep 17 00:00:00 2001 From: Angie Byron <webchick@24967.no-reply.drupal.org> Date: Tue, 13 Oct 2009 07:09:26 +0000 Subject: [PATCH] #559294 by David_Rothstein: Allow install profiles to alter or override the task list. --- install.php | 14 +++++++++++++- modules/system/system.api.php | 19 ++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/install.php b/install.php index d727e65fe96e..0a53ebf6a192 100644 --- a/install.php +++ b/install.php @@ -567,7 +567,7 @@ function install_tasks($install_state) { // Now add any tasks defined by the installation profile. if (!empty($install_state['parameters']['profile'])) { - $function = $install_state['parameters']['profile'] . '_profile_tasks'; + $function = $install_state['parameters']['profile'] . '_install_tasks'; if (function_exists($function)) { $result = $function($install_state); if (is_array($result)) { @@ -589,6 +589,18 @@ function install_tasks($install_state) { ), ); + // Allow the installation profile to modify the full list of tasks. + if (!empty($install_state['parameters']['profile'])) { + $profile_file = DRUPAL_ROOT . '/profiles/' . $install_state['parameters']['profile'] . '/' . $install_state['parameters']['profile'] . '.profile'; + if (is_file($profile_file)) { + include_once $profile_file; + $function = $install_state['parameters']['profile'] . '_install_tasks_alter'; + if (function_exists($function)) { + $function($tasks, $install_state); + } + } + } + // Fill in default parameters for each task before returning the list. foreach ($tasks as $task_name => &$task) { $task += array( diff --git a/modules/system/system.api.php b/modules/system/system.api.php index 186899273c45..2826cdbc6340 100644 --- a/modules/system/system.api.php +++ b/modules/system/system.api.php @@ -2175,7 +2175,7 @@ function hook_registry_files_alter(&$files, $module_cache) { * @see install_state_defaults() * @see batch_set() */ -function hook_profile_tasks() { +function hook_install_tasks() { // Here, we define a variable to allow tasks to indicate that a particular, // processor-intensive batch process needs to be triggered later on in the // installation. @@ -2256,6 +2256,23 @@ function hook_drupal_goto_alter(array $args) { $args['http_response_code'] = 500; } +/** + * Alter the full list of installation tasks. + * + * @param $tasks + * An array of all available installation tasks, including those provided by + * Drupal core. You can modify this array to change or replace any part of + * the Drupal installation process that occurs after the installation profile + * is selected. + * @param $install_state + * An array of information about the current installation state. + */ +function hook_install_tasks_alter(&$tasks, $install_state) { + // Replace the "Choose language" installation task provided by Drupal core + // with a custom callback function defined by this installation profile. + $tasks['install_select_locale']['function'] = 'myprofile_locale_selection'; +} + /** * Alter MIME type mappings used to determine MIME type from a file extension. * -- GitLab