change getLanguageSwitchLinks() to return an array instead of a weird object

Created on 26 September 2023, over 1 year ago

Problem/Motivation

The return of LanguageManagerInterface::getLanguageSwitchLinks() is this:

   * @return object|null
   *   An object with the following keys:
   *   - links: An array of links indexed by the language ID
   *   - method_id: The language negotiation method ID
   *   or NULL if there are no language switch links.

This seems really bizarre. You can't iterate over it. You have to check if it's NULL or not before you try to access it, because it might not actually be an object.

I can only find one instance in core of the method_id, in LanguageBlock:

            "language-switcher-{$links->method_id}",

It also differs from the same named method on LanguageSwitcherInterface, which is confusing.

Steps to reproduce

Proposed resolution

Change the method to return an array. Add a separate method to get the method_id.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

📌 Task
Status

Active

Version

11.0 🔥

Component
Language system 

Last updated 7 days ago

  • Maintained by
  • 🇩🇪Germany @sun
Created by

🇬🇧United Kingdom joachim

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024