From 99eb69434a3ffbdd4af33085869dfe3127e01dee Mon Sep 17 00:00:00 2001 From: Michael Stenta Date: Mon, 6 Sep 2021 09:00:25 -0400 Subject: [PATCH] Install Gin via farm_ui_theme_install() instead of config/install. --- config/install/system.file.yml | 3 - config/install/system.theme.yml | 2 - farm.info.yml | 2 +- farm.install | 9 +++ .../install/block.block.farm_powered.yml | 19 ------ .../ui/theme/config/rewrite/gin.settings.yml | 8 --- modules/ui/theme/farm_ui_theme.info.yml | 3 +- modules/ui/theme/farm_ui_theme.install | 63 +++++++++++++++++++ 8 files changed, 74 insertions(+), 35 deletions(-) delete mode 100644 config/install/system.file.yml delete mode 100644 config/install/system.theme.yml delete mode 100644 modules/ui/theme/config/install/block.block.farm_powered.yml delete mode 100644 modules/ui/theme/config/rewrite/gin.settings.yml create mode 100644 modules/ui/theme/farm_ui_theme.install diff --git a/config/install/system.file.yml b/config/install/system.file.yml deleted file mode 100644 index 01c19373e..000000000 --- a/config/install/system.file.yml +++ /dev/null @@ -1,3 +0,0 @@ -allow_insecure_uploads: false -default_scheme: private -temporary_maximum_age: 21600 diff --git a/config/install/system.theme.yml b/config/install/system.theme.yml deleted file mode 100644 index dada13331..000000000 --- a/config/install/system.theme.yml +++ /dev/null @@ -1,2 +0,0 @@ -admin: '' -default: gin diff --git a/farm.info.yml b/farm.info.yml index 15a8fa25f..245a407db 100644 --- a/farm.info.yml +++ b/farm.info.yml @@ -17,4 +17,4 @@ dependencies: { } install: - dblog themes: - - gin + - claro diff --git a/farm.install b/farm.install index e50d18411..7fbb63b84 100644 --- a/farm.install +++ b/farm.install @@ -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(). */ diff --git a/modules/ui/theme/config/install/block.block.farm_powered.yml b/modules/ui/theme/config/install/block.block.farm_powered.yml deleted file mode 100644 index ae6dd3c2a..000000000 --- a/modules/ui/theme/config/install/block.block.farm_powered.yml +++ /dev/null @@ -1,19 +0,0 @@ -langcode: en -status: true -dependencies: - module: - - farm_ui_theme - theme: - - claro -id: farm_powered -theme: claro -region: content -weight: 1000 -provider: null -plugin: farm_powered_by_block -settings: - id: farm_powered_by_block - label: 'Powered by farmOS' - provider: farm_ui_theme - label_display: '0' -visibility: { } diff --git a/modules/ui/theme/config/rewrite/gin.settings.yml b/modules/ui/theme/config/rewrite/gin.settings.yml deleted file mode 100644 index b7a51efe4..000000000 --- a/modules/ui/theme/config/rewrite/gin.settings.yml +++ /dev/null @@ -1,8 +0,0 @@ -classic_toolbar: vertical -preset_accent_color: green -preset_focus_color: orange -icon_default: false -icon_path: 'profiles/farm/modules/ui/theme/logo.png' -favicon: - use_default: false - path: 'profiles/farm/modules/ui/theme/favicon.ico' diff --git a/modules/ui/theme/farm_ui_theme.info.yml b/modules/ui/theme/farm_ui_theme.info.yml index 870798bd9..5c6657c82 100644 --- a/modules/ui/theme/farm_ui_theme.info.yml +++ b/modules/ui/theme/farm_ui_theme.info.yml @@ -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 diff --git a/modules/ui/theme/farm_ui_theme.install b/modules/ui/theme/farm_ui_theme.install new file mode 100644 index 000000000..d571450dd --- /dev/null +++ b/modules/ui/theme/farm_ui_theme.install @@ -0,0 +1,63 @@ +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(); +}