Problem/Motivation

I am getting entity URL by programatically setting the domain.

Steps to reproduce

Create two domains called us, ca.
US domain - example.com/us
Ca domain - example.com/ca
I am using country path module for domain prefix.

Node 1 is associated in US, CA.
Set the domain programatically and get the entity URL using $entity->toUrl(); Now Url object doesn't changing the based on the domain.

What I am expecting.
So when load node 1 URL in code, I am expecting below output.
1. /us/node/1 - For US domain.
2. /ca/node/1 - For CA domain.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#8 active_domain-3175755-8.patch751 bytestrishen
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

iyyappan.govind created an issue. See original summary.

iyyappan.govind’s picture

Issue summary: View changes
iyyappan.govind’s picture

Issue summary: View changes
agentrickard’s picture

Category: Bug report » Support request
agentrickard’s picture

How are you trying to Set the domain programatically?

This may be a country path issue.

iyyappan.govind’s picture

Hi
I am trying to set the domain like below.

$domain = Domain::load('us'); // Load domain
\Drupal::service('domain.negotiator')->setActiveDomain($domain);

Thanks

agentrickard’s picture

Title: Can't set Domain programatically » Paths not set as expected when setActiveDomain() used
Project: Domain » Domain Country Path

Re-filing to Country Path.

trishen’s picture

StatusFileSize
new751 bytes

@iyyappan.govind
with this patch, you can set domain as URL option

  $domain = Domain::load('us');
  $url = $entity->toUrl();
  $url->setOption('active_domain', $domain);
trishen’s picture

Status: Active » Needs review
d.fisher’s picture

The patch no longer applies. Going to create a branch and merge request.

d.fisher’s picture

Here is an updated remote patch URL for testing:
https://git.drupalcode.org/project/country_path/-/merge_requests/28.patch

d.fisher’s picture

Tested the merge request and it applies cleanly and continues to solve this issue. Would be good to get this one across the line after 5 years of being in 'needs review'. Can we get another +1 for RTBC?

d.fisher’s picture

MR!28 is working well for our use case and I'd be keen to move this issue along if it's working for others too. Any chance we can get a +1 for RTBC from @iyyappan.govind, @agentrickard, or @trishen?

trishen’s picture

Status: Needs review » Reviewed & tested by the community

Reviewed

d.fisher’s picture

Ok let's get this one merged.

d.fisher’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.