From 0f6ec5533c56912dd1dcbc9c35a02993e8e2fffd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Kalij=C3=A4rvi?= Date: Wed, 28 Feb 2024 10:55:16 +0200 Subject: [PATCH 1/2] Update development.md --- documentation/development.md | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/documentation/development.md b/documentation/development.md index d76875729..c4e5dc02c 100644 --- a/documentation/development.md +++ b/documentation/development.md @@ -230,10 +230,23 @@ The update hook above will re-import all configuration from `helfi_media` module The `helfi_platform_config.config_update_helper` invokes `hook_rewrite_config_update`, which allows custom modules to react to config re-importing. ```php -function helfi_kasko_content_rewrite_config_update(string $module, Drupal\config_rewrite\ConfigRewriterInterface $configRewriter): void { - if ($module === 'helfi_tpr_config') { - // Rewrite helfi_tpr_config configuration. - $configRewriter->rewriteModuleConfig('helfi_kasko_content'); +function my_module_rewrite_config_update(string $module, Drupal\config_rewrite\ConfigRewriterInterface $configRewriter): void { + if ($module === 'helfi_paragraphs_text') { + // Rewrite helfi_paragraphs_text configuration. + $configRewriter->rewriteModuleConfig('my_module'); } } ``` +In this example we would want to override Text paragraph label with a configuration found in my_module. +To override configurations for your Drupal instance, follow the instructions found in [Rewrite module project page](https://www.drupal.org/project/config_rewrite). + +In our example, the label change would be implemented in a configuration file `/public/modules/custom/my_module/config/rewrite/paragraphs.paragraphs_type.text.yml`: +```yml +label: Text (override) +``` +The label change for the Finnish translation would be implemented in a configuration file `/public/modules/custom/my_module/config/rewrite/language/fi/paragraphs.paragraphs_type.text.yml` +```yml +label: Teksti (ylikirjoitettu) +``` + + From 342ae3c42c00840913d7a5f0d357da9532136b22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Kalij=C3=A4rvi?= Date: Wed, 28 Feb 2024 11:05:00 +0200 Subject: [PATCH 2/2] Update development.md --- documentation/development.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/documentation/development.md b/documentation/development.md index c4e5dc02c..0bfecacae 100644 --- a/documentation/development.md +++ b/documentation/development.md @@ -229,6 +229,9 @@ The update hook above will re-import all configuration from `helfi_media` module The `helfi_platform_config.config_update_helper` invokes `hook_rewrite_config_update`, which allows custom modules to react to config re-importing. +##### In this example we would want to override Text paragraph label with a configuration found in my_module. + +To trigger the `hook_rewrite_config_update`, implement the hook to your `my_module.module`: ```php function my_module_rewrite_config_update(string $module, Drupal\config_rewrite\ConfigRewriterInterface $configRewriter): void { if ($module === 'helfi_paragraphs_text') { @@ -237,7 +240,8 @@ function my_module_rewrite_config_update(string $module, Drupal\config_rewrite\C } } ``` -In this example we would want to override Text paragraph label with a configuration found in my_module. +This hook will trigger when `\Drupal::service('helfi_platform_config.config_update_helper')->update('helfi_paragraphs_text');` is run and it will search for configurations in `my_module/config/rewrite/` folder. + To override configurations for your Drupal instance, follow the instructions found in [Rewrite module project page](https://www.drupal.org/project/config_rewrite). In our example, the label change would be implemented in a configuration file `/public/modules/custom/my_module/config/rewrite/paragraphs.paragraphs_type.text.yml`: