Allow for explicitly specifying domain for getPathByAlias() and getAliasByPath() method

Created on 28 March 2025, 16 days ago

Problem/Motivation

Currently, when calling getPathByAlias() or getAliasByPath(), the domain that is used for the lookups is always the currently active domain:

$active = \Drupal::service('domain.negotiator')->getActiveDomain();

I have a scenario where I need to fetch the alias for a specific domain, which the method does not allow.

Proposed resolution

Allow for an optional domain argument, that uses that specific domain to get the alias from. Since it's nullable, and will be added to the end of the function signature, it will not have BC implications.

If it isn't set, defaults to current behavior (Fetch the currently active domain).

API changes

DomainPathAliasManager::getAliasByPath() and DomainPathAliasManager::getPathByAlias() can now be called with an extra Domain parameter, to fetch the alias for that specific domain.

Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇵🇹Portugal gueguerreiro Lisboa

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024