Skip to content

Commit

Permalink
Create a concept of "base" modules that are always installed.
Browse files Browse the repository at this point in the history
These will not appear in the farmOS modules form, but can be uninstalled
manually if a more customized deployment is desired.
  • Loading branch information
mstenta committed Mar 18, 2021
1 parent 30ba783 commit 53ceae8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
7 changes: 6 additions & 1 deletion farm.install
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ function farm_install_tasks_alter(&$tasks, $install_state) {
*/
function farm_install_modules(array &$install_state) {

// Load the list of farmOS core modules.
$all = farm_modules();

// Load the list of modules that should be installed.
// If provided, use the modules defined in farm_install_modules.module
// profile arguments. We assume this is an array of module machine names,
Expand All @@ -62,16 +65,18 @@ function farm_install_modules(array &$install_state) {
$modules_arg = $install_state['forms']['farm']['modules'];
if ($modules_arg === 'all') {
$all = farm_modules();
$modules = array_merge(array_keys($all['default']), array_keys($all['optional']));
$modules = array_merge(array_keys($all['base']), array_keys($all['default']), array_keys($all['optional']));
}
else {
$modules = Json::decode($modules_arg);
}
}

// Use the state set by the \Drupal\farm\Form\FarmModulesForm submit method.
// Merge base modules into it.
else {
$modules = \Drupal::state()->get('farm.install_modules') ?: [];
$modules = array_merge(array_keys($all['base']), $modules);
}

// If this is running in the context of a functional test, do not install any
Expand Down
11 changes: 8 additions & 3 deletions farm.profile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@
* Define farmOS modules that can be installed.
*
* @return array
* Returns an array with two sub-arrays: 'default' and 'optional'. Default
* modules will be selected for installation by default, and optional modules
* will require the user to select them for installation.
* Returns an array with three sub-arrays: 'base', 'default' and 'optional'.
* Base modules will always be installed, but can be uninstalled. Default and
* optional modules will appear as options during farmOS installation and in
* a form available to admins. During initial farmOS installation, default
* modules will be selected by default, and optional modules will require the
* user to select them for installation.
*/
function farm_modules() {
return [
'base' => [
],
'default' => [
'farm_land' => t('Land assets'),
'farm_plant' => t('Plant assets'),
Expand Down

0 comments on commit 53ceae8

Please sign in to comment.