From ca2095144f608758ee55fc9cbe0dee1f9b733838 Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Tue, 9 Jul 2024 16:52:15 +0300 Subject: [PATCH 1/3] UHF-9741: Add first_paragraph_grey alter --- helfi_platform_config.api.php | 25 +++++++++++++++++++++++++ src/Plugin/Block/ContentBlockBase.php | 11 +++++++++++ src/Plugin/Block/HeroBlock.php | 3 +++ 3 files changed, 39 insertions(+) create mode 100644 helfi_platform_config.api.php diff --git a/helfi_platform_config.api.php b/helfi_platform_config.api.php new file mode 100644 index 000000000..0eb428406 --- /dev/null +++ b/helfi_platform_config.api.php @@ -0,0 +1,25 @@ +entityTypeManager = $entity_type_manager; $this->entityVersionMatcher = $entity_version_matcher; + $this->moduleHandler = $module_handler; } /** @@ -60,6 +70,7 @@ public static function create( $plugin_definition, $container->get('entity_type.manager'), $container->get('helfi_platform_config.entity_version_matcher'), + $container->get('module_handler'), ); } diff --git a/src/Plugin/Block/HeroBlock.php b/src/Plugin/Block/HeroBlock.php index 6ebd5270b..22f754308 100644 --- a/src/Plugin/Block/HeroBlock.php +++ b/src/Plugin/Block/HeroBlock.php @@ -56,6 +56,9 @@ public function build() : array { 'service_list_search', ]; + // Let modules alter the array of paragraphs with grey background. + $this->moduleHandler->alter('first_paragraph_grey', $paragraphs_with_grey_bg); + if ( $paragraph instanceof ParagraphInterface && in_array($paragraph->getType(), $paragraphs_with_grey_bg) From 2af2fc67b677fabc0dc72e36917e8b84e0149ef4 Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Wed, 10 Jul 2024 11:07:49 +0300 Subject: [PATCH 2/3] UHF-9741: Fix phpcs --- .../helfi_eu_cookie_compliance.install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/helfi_eu_cookie_compliance/helfi_eu_cookie_compliance.install b/modules/helfi_eu_cookie_compliance/helfi_eu_cookie_compliance.install index 26792101d..dbf36bd0d 100644 --- a/modules/helfi_eu_cookie_compliance/helfi_eu_cookie_compliance.install +++ b/modules/helfi_eu_cookie_compliance/helfi_eu_cookie_compliance.install @@ -91,4 +91,4 @@ function helfi_eu_cookie_compliance_update_9011(): void { function helfi_eu_cookie_compliance_update_9012(): void { \Drupal::service('helfi_platform_config.config_update_helper') ->update('helfi_eu_cookie_compliance'); -} \ No newline at end of file +} From 7fa6b0a076627a93e3bea478d138f17f9c455692 Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Thu, 11 Jul 2024 14:21:45 +0300 Subject: [PATCH 3/3] UHF-9741: Document first_paragraph_grey_alter usage --- documentation/development.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/documentation/development.md b/documentation/development.md index 869427a70..652b6564a 100644 --- a/documentation/development.md +++ b/documentation/development.md @@ -305,3 +305,25 @@ final class YourEntityImageBuilder implements OGImageBuilderInterface { } ``` + + +## First paragraph grey alter + +There are some paragraphs that we want to "blend" with the hero-block if they are directly after the hero such as +searches. Good example of this kind of search is `unit_search`. The grey background should continue from hero to the +paragraph seamlessly and for paragraphs that are usable on all instances this is done in the `helfi_platform_config`. +These paragraphs can be found listed in the `$paragraphs_with_grey_bg` variable in `HeroBlock.php`. + +There can be paragraphs that we want to function this way, but they are instance specific. For them to be able to +function the same way you need to use the `first_paragraph_grey_alter` on that instance that uses the paragraph. + +Here is an example on how this is done in front page instance (helfi_etusivu custom module, helfi_etusivu.module file): + +```php +/** +* Implements hook_first_paragraph_grey_alter(). +*/ +function helfi_etusivu_first_paragraph_grey_alter(array &$paragraphs): void { + $paragraphs[] = 'news_archive'; +} +```