Implement install and uninstall hooks for module #59
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Creates directory public://localgov_publications_importer when module is installed. Deletes public://localgov_publications_importer when module is uninstalled.
What does this change?
This change ensures that the module automatically creates the required directory public://localgov_publications_importer during installation and removes it during uninstallation.
Previously, this directory had to be created manually, which could lead to errors if forgotten. Automating this step improves reliability and reduces setup friction.
How it works:
Implements hook_install() to create the directory using Drupal’s file_system service.
Implements hook_uninstall() to remove the directory recursively.
How to test
On main:
Install the module.
Observe that public://localgov_publications_importer does not exist unless manually created.
On this branch:
Install the module.
Confirm that public://localgov_publications_importer is automatically created.
Uninstall the module.
Confirm that the directory is removed.
How can we measure success?
No manual steps required for directory creation.
No errors related to missing directory during module usage.
Clean uninstall without leaving orphaned directories.
Have we considered potential risks?
Risk: Directory deletion on uninstall could remove files if they were manually added by a site admin