Add hook to allow altering $links in DropdownLanguage block class

Created on 16 August 2024, 8 months ago
Updated 23 August 2024, 8 months ago

Problem/Motivation

I need to be able to alter the languages.

Proposed resolution

Add alter hook.

Feature request
Status

Active

Version

4.0

Component

Code

Created by

🇬🇧United Kingdom dahousecat

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

  • Issue created by @dahousecat
  • 🇬🇧United Kingdom dahousecat

    Patch to:
    - Add call to moduleHandler->invokeAll for new hook_dropdown_language_alter_links hook.
    - Add dropdown_language.api.php to document new hook.

  • 🇨🇦Canada SKAUGHT

    would you be able to outline the advantage of this hook? simply, what is your use-case that you need to alter the like that you can not 'use custom title' not be useful??

    also: needs tests.

  • 🇬🇧United Kingdom dahousecat

    @skaught certainly.

    In my case all child pages belong to properties.
    Properties can enable and disable languages manually via a field.
    Translations may get added for child pages at any point, however until we want to enable a language for a property none of the translations for child pages should show.

    This means I need to apply custom logic specific to my application to alter the available links.

    Also there are certain languages that we always want to show even if translations don't exist.

    This patch alone will not achieve that as link will have already been unset by the time the alter hooks runs - so I think I'll create another issue for this too.

Production build 0.71.5 2024