Country path not managed in domain navigation block

Created on 16 April 2018, almost 7 years ago
Updated 13 February 2024, about 1 year ago

Hi

when I use country path on a D8 website, with "domain", I do not have the country path on the "domain navigation" block provided by "domain" module.

The code from "domain", located on DomainNavBlock.php (line 111):

foreach (\Drupal::service('entity_type.manager')->getStorage('domain')->loadMultipleSorted() as $domain) {
      // Set the URL.
      $options = ['absolute' => TRUE, 'https' => ($domain->getScheme() == 'https')];
      if ($add_path) {
        $url = Url::fromUri($domain->getUrl(), $options);
      }
      else {
        $url = Url::fromUri($domain->getPath(), $options);
      }

...
}

does not manage the country path provided in the "thirdParty" attribute.

This results the domain URL list does not display the country path.

My proposed patch: add, at the end of the "CountryPathDomain.php" the setPath() and setUrl() with a test on the $this->getThirdPartySetting('country_path', 'domain_path'):

  /**
   * {@inheritdoc}
   */
  public function setPath() {
    parent::setPath();
    if ($countryPath = $this->getThirdPartySetting('country_path', 'domain_path')) {
      $this->path .= $countryPath . '/';
    }
  }

  /**
   * {@inheritdoc}
   */
  public function setUrl() {
    $uri = \Drupal::request()->getRequestUri();
    if ($countryPath = $this->getThirdPartySetting('country_path', 'domain_path')) {
      $this->url = $this->getScheme() . $this->getHostname() . '/' . $countryPath . $uri;
    }
    else {
      $this->url = $this->getScheme() . $this->getHostname() . $uri;
    }
  }

Tested on my configuration and works fine.

My Domain configuration:

  Domain                                  Country path (country_path)                                       Enabled
  Domain                                  Domain (domain)                                                   Enabled    8.x-1.0-alpha13
  Domain                                  Domain Access (domain_access)                                     Enabled    8.x-1.0-alpha13
  Domain                                  Domain Configuration (domain_config)                              Enabled    8.x-1.0-alpha13
  Domain                                  Domain Content (domain_content)                                   Enabled    8.x-1.0-alpha13
  Domain                                  Domain Language (domain_language)                                 Enabled    8.x-1.0-alpha1
  Domain                                  Domain Source (domain_source)                                     Enabled    8.x-1.0-alpha13

Could you please review my patch, and apply it if it's good !

Thanks
Nicolas.

πŸ› Bug report
Status

Needs work

Version

1.0

Component

Code

Created by

πŸ‡«πŸ‡·France nbourdial

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

Merge Requests

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