Skip to content

Commit

Permalink
Install Gin via farm_ui_theme_install() instead of config/install.
Browse files Browse the repository at this point in the history
  • Loading branch information
mstenta committed Sep 6, 2021
1 parent 453063f commit 99eb694
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 35 deletions.
3 changes: 0 additions & 3 deletions config/install/system.file.yml

This file was deleted.

2 changes: 0 additions & 2 deletions config/install/system.theme.yml

This file was deleted.

2 changes: 1 addition & 1 deletion farm.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ dependencies: { }
install:
- dblog
themes:
- gin
- claro
9 changes: 9 additions & 0 deletions farm.install
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@

use Drupal\Component\Serialization\Json;

/**
* Implements hook_install().
*/
function farm_install() {

// Use private file system by default.
\Drupal::configFactory()->getEditable('system.file')->set('default_scheme', 'private')->save();
}

/**
* Implements hook_install_tasks().
*/
Expand Down
19 changes: 0 additions & 19 deletions modules/ui/theme/config/install/block.block.farm_powered.yml

This file was deleted.

8 changes: 0 additions & 8 deletions modules/ui/theme/config/rewrite/gin.settings.yml

This file was deleted.

3 changes: 1 addition & 2 deletions modules/ui/theme/farm_ui_theme.info.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: farmOS UI Theme
description: Provides Gin theme overrides for farmOS.
description: Install Gin theme and provide overrides for farmOS.
type: module
package: farmOS UI
core_version_requirement: ^9
dependencies:
- config_rewrite:config_rewrite
- drupal:block
63 changes: 63 additions & 0 deletions modules/ui/theme/farm_ui_theme.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

/**
* @file
* Install, update and uninstall functions for the farm_ui_theme module.
*/

use Drupal\block\Entity\Block;

/**
* Implements hook_install().
*/
function farm_ui_theme_install() {

// Install the Gin theme and make it the default.
\Drupal::service('theme_installer')->install(['gin']);
\Drupal::configFactory()->getEditable('system.theme')->set('default', 'gin')->save();

// Load Gin settings.
$gin_settings = \Drupal::configFactory()->getEditable('gin.settings');

// Use vertical toolbar.
$gin_settings->set('classic_toolbar', 'vertical');

// Use green/orange color palette.
$gin_settings->set('preset_accent_color', 'green');
$gin_settings->set('preset_focus_color', 'orange');

// Use farmOS logo and favicon.
$gin_settings->set('icon_default', FALSE);
$gin_settings->set('icon_path', drupal_get_path('module', 'farm_ui_theme') . '/logo.png');
$gin_settings->set('favicon.use_default', FALSE);
$gin_settings->set('favicon.path', drupal_get_path('module', 'farm_ui_theme') . '/favicon.ico');

// Save Gin settings.
$gin_settings->save();

// Create the "Powered by farmOS" block.
// This must be done in hook_install() instead of config/install because Gin
// needs to be installed first.
$values = [
'id' => 'farm_powered',
'plugin' => 'farm_powered_by_block',
'theme' => 'gin',
'region' => 'content',
'weight' => 1000,
'settings' => [
'id' => 'farm_powered_by_block',
'label' => t('Powered by farmOS'),
'provider' => 'farm_ui_theme',
'label_display' => '0',
],
'visibility' => [],
'dependencies' => [
'enforced' => [
'module' => [
'farm_ui_theme',
],
],
],
];
Block::create($values)->save();
}

0 comments on commit 99eb694

Please sign in to comment.