Allow domain to be passed into processOutbound manually

Created on 7 June 2021, over 3 years ago
Updated 4 April 2024, 6 months ago

Problem/Motivation

As processOutbound calls getActiveDomain, outbound URLs are always relative to the request URI.

For my use case, I need the ability to programmatically generate links for a given domain regardless of the originating request URL.

Proposed resolution

I've updated processOutbound to check if a domain entity has been passed in via options, and if not default to getActiveDomain.

The merge request below allows you to pass the CountryPathDomain entity in a new 'domain' option, for example:

/** @var \Drupal\language\Entity\ConfigurableLanguage $language */
$language = \Drupal::entityTypeManager()->getStorage('configurable_language')->load('de');

/** @var \Drupal\country_path\Entity\CountryPathDomain $domain */
$domain = \Drupal::entityTypeManager()->getStorage('domain')->load('fr');

$url = URL::fromRoute('entity.node.canonical', ['node' => 1], ['domain' => $domain, 'language' => $language]);
$url_string = $url->toString();
Feature request
Status

Closed: duplicate

Version

1.0

Component

Code

Created by

🇬🇧United Kingdom JamieP

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024