2 * Implements hook_install_tasks().
4 function {{ machine_name }}_install_tasks(&$install_state) {
5 // Here, we define a variable to allow tasks to indicate that a particular,
6 // processor-intensive batch process needs to be triggered later on in the
8 $myprofile_needs_batch_processing = \Drupal::state()->get('myprofile.needs_batch_processing', FALSE);
10 // This is an example of a task that defines a form which the user who is
11 // installing the site will be asked to fill out. To implement this task,
12 // your profile would define a function named myprofile_data_import_form()
13 // as a normal form API callback function, with associated validation and
14 // submit handlers. In the submit handler, in addition to saving whatever
15 // other data you have collected from the user, you might also call
16 // \Drupal::state()->set('myprofile.needs_batch_processing', TRUE) if the
17 // user has entered data which requires that batch processing will need to
19 'myprofile_data_import_form' => [
20 'display_name' => t('Data import options'),
23 // Similarly, to implement this task, your profile would define a function
24 // named myprofile_settings_form() with associated validation and submit
25 // handlers. This form might be used to collect and save additional
26 // information from the user that your profile needs. There are no extra
27 // steps required for your profile to act as an "installation wizard"; you
28 // can simply define as many tasks of type 'form' as you wish to execute,
29 // and the forms will be presented to the user, one after another.
30 'myprofile_settings_form' => [
31 'display_name' => t('Additional options'),
34 // This is an example of a task that performs batch operations. To
35 // implement this task, your profile would define a function named
36 // myprofile_batch_processing() which returns a batch API array definition
37 // that the installer will use to execute your batch operations. Due to the
38 // 'myprofile.needs_batch_processing' variable used here, this task will be
39 // hidden and skipped unless your profile set it to TRUE in one of the
41 'myprofile_batch_processing' => [
42 'display_name' => t('Import additional data'),
43 'display' => $myprofile_needs_batch_processing,
45 'run' => $myprofile_needs_batch_processing ? INSTALL_TASK_RUN_IF_NOT_COMPLETED : INSTALL_TASK_SKIP,
47 // This is an example of a task that will not be displayed in the list that
48 // the user sees. To implement this task, your profile would define a
49 // function named myprofile_final_site_setup(), in which additional,
50 // automated site setup operations would be performed. Since this is the
51 // last task defined by your profile, you should also use this function to
52 // call \Drupal::state()->delete('myprofile.needs_batch_processing') and
53 // clean up the state that was used above. If you want the user to pass
54 // to the final Drupal installation tasks uninterrupted, return no output
55 // from this function. Otherwise, return themed output that the user will
56 // see (for example, a confirmation page explaining that your profile's
57 // tasks are complete, with a link to reload the current page and therefore
58 // pass on to the final Drupal installation tasks when the user is ready to
60 'myprofile_final_site_setup' => [