Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

Define install tasks for choosing the site template and add-ons #151

Merged
merged 7 commits into from
Jul 31, 2024

Conversation

narendra-drupal
Copy link
Contributor

While working on this I found that if we try to install starshot in other language it gives error Drupal\Core\DefaultContent\InvalidEntityException: recipes/starshot/content/user/c6fc2154-25c0-4b9d-ad4d-8d04a6a52f05.yml: preferred_langcode.0.value=The value you selected is not a valid choice.||preferred_langcode.0=The value you selected is not a valid choice.||preferred_admin_langcode.0.value=The value you selected is not a valid choice.||preferred_admin_langcode.0=The value you selected is not a valid choice. in Drupal\Core\DefaultContent\Importer->importContent() (line 113 of Sites/starshot/web/core/lib/Drupal/Core/DefaultContent/Importer.php).

@phenaproxima
Copy link
Owner

Oooh, I think I see the problem you mention, @narendra-drupal. It's not in scope here, but the default content in Starshot is in the English language. The thing we probably need to do is move the demo content to its own recipe, and have it explicitly install in English only.

@phenaproxima
Copy link
Owner

I tested this at the command line and one problem we have is that, if you run vendor/bin/drush cget core.extension, you'll see this at the end:

profile: starshot_installer

It should be false, I think. So the installer isn't getting uninstalled, which is a problem. We probably should add test coverage; doing that in my next commit.

@phenaproxima
Copy link
Owner

The closer I look at this, the more troublesome it becomes...

I think what we might need to do here is actually not use hook_install_tasks_alter(), but rather, create a new install task as part of the installer that allows you to choose a recipe, and then ensure that recipe is applied by starshot_installer_apply_recipes(). Obviously, for now the choice of recipe is hard-coded but ideally we'd later replace that with a real choice.

@phenaproxima
Copy link
Owner

phenaproxima commented Jul 30, 2024

After discussion with @timplunkett, I think we should change the approach here. We should not use hook_install_tasks_alter(), but instead we should define two additional install tasks beyond what's in HEAD.

  1. Choose your template: this is where you'd choose whether to start from the Starshot base recipe, or a commerce recipe, or a headless recipe, or...whatever. For now, this should hard-code the choice of recipe to recipes/starshot, and not present anything to the user. It should save the choice in $install_state['parameters']['template'] or similar. starshot_installer_apply_recipes() should use that install parameter to apply the chosen recipe, rather than hardcode recipes/starshot. That can all be done in one PR (this one).
  2. Choose additional recipes: after the template is applied, this is where we'd show additional recipes for people to add, probably by using a mini-Project Browser. For now, this can just be an empty callback function. We can do this in a second PR.

To put it another way: you cannot skip the installer, and you cannot install the site from a recipe instead of using the starshot_installer profile. But the profile should define additional steps that let you choose a base recipe (the "main course", if you like), and some add-ons (the side dishes). And then, it uninstalls itself.

@narendra-drupal
Copy link
Contributor Author

After discussion with @timplunkett, I think we should change the approach here. We should not use hook_install_tasks_alter(), but instead we should define two additional install tasks beyond what's in HEAD.

  1. Choose your template: this is where you'd choose whether to start from the Starshot base recipe, or a commerce recipe, or a headless recipe, or...whatever. For now, this should hard-code the choice of recipe to recipes/starshot, and not present anything to the user. It should save the choice in $install_state['parameters']['template'] or similar. starshot_installer_apply_recipes() should use that install parameter to apply the chosen recipe, rather than hardcode recipes/starshot. That can all be done in one PR (this one).
  2. Choose additional recipes: after the template is applied, this is where we'd show additional recipes for people to add, probably by using a mini-Project Browser. For now, this can just be an empty callback function. We can do this in a second PR.

To put it another way: you cannot skip the installer, and you cannot install the site from a recipe instead of using the starshot_installer profile. But the profile should define additional steps that let you choose a base recipe (the "main course", if you like), and some add-ons (the side dishes). And then, it uninstalls itself.

Done

@phenaproxima phenaproxima changed the title Hook install_tasks_alter used instead of install_tasks Define install tasks for choosing the site template and add-ons Jul 31, 2024
@phenaproxima phenaproxima merged commit 429228d into phenaproxima:main Jul 31, 2024
4 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants