Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds new install step, which calls a new hook. #751

Merged
merged 2 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions localgov.api.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/**
* @file
* Hooks provided by the LocalGov install profile.
*/

/**
* @addtogroup hooks
* @{
*/

/**
* Run a task during the site installation process.
*
* This is intended for work that needs to happen when installing a localgov
* site, that can't happen in a module's hook_install(). This hook is invoked
* later in the install process, when everything bar the importing of
* translations is done.
*
* It can also be used to only run code during a site install, and not when a
* module is installed in an existing site.
*/
function hook_localgov_post_install(): void {
// Whatever your module needs to do goes here.
}

/**
* @} End of "addtogroup hooks".
*/
25 changes: 25 additions & 0 deletions localgov.profile
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,28 @@ function localgov_page_attachments(array &$attachments): void {
}
}
}

/**
* Implements hook_install_tasks().
*/
function localgov_install_tasks(array &$install_state): array {
return [
'localgov_post_install_task' => [
'display_name' => t('Localgov post install'),
'display' => TRUE,
],
];
}

/**
* This is an install step, added by localgov_install_tasks().
*
* We use this step to call a hook to allow other localgov modules to set things
* up as part of the site installation process that they can't do in their
* install hooks.
*/
function localgov_post_install_task(): void {
\Drupal::moduleHandler()->invokeAllWith('localgov_post_install', function (callable $hook, string $module) {
$hook();
});
}
Loading