Commit 0e507e42 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #1810394 by hchonov, plach, YesCT, David Hernández, Schnitzel,...

Issue #1810394 by hchonov, plach, YesCT, David Hernández, Schnitzel, vijaycs85, penyaskito, tstoeckler, alexpott, Gábor Hojtsy: Site configuration with domain based language negotiation results in redirecting authenticated users to a different domain when accessing a content entity route for translation language different from the interface language
parent 20621c28
Loading
Loading
Loading
Loading
+21 −2
Original line number Diff line number Diff line
@@ -21,8 +21,27 @@ interface OutboundPathProcessorInterface {
   * @param string $path
   *   The path to process, with a leading slash.
   * @param array $options
   *   An array of options such as would be passed to the generator's
   *   generateFromRoute() method.
   *   (optional) An associative array of additional options, with the following
   *   elements:
   *   - 'query': An array of query key/value-pairs (without any URL-encoding)
   *     to append to the URL.
   *   - 'fragment': A fragment identifier (named anchor) to append to the URL.
   *     Do not include the leading '#' character.
   *   - 'absolute': Defaults to FALSE. Whether to force the output to be an
   *     absolute link (beginning with http:). Useful for links that will be
   *     displayed outside the site, such as in an RSS feed.
   *   - 'language': An optional language object used to look up the alias
   *     for the URL. If $options['language'] is omitted, it defaults to the
   *     current language for the language type LanguageInterface::TYPE_URL.
   *   - 'https': Whether this URL should point to a secure location. If not
   *     defined, the current scheme is used, so the user stays on HTTP or HTTPS
   *     respectively. TRUE enforces HTTPS and FALSE enforces HTTP.
   *   - 'base_url': Only used internally by a path processor, for example, to
   *     modify the base URL when a language dependent URL requires so.
   *   - 'prefix': Only used internally, to modify the path when a language
   *     dependent URL requires so.
   *   - 'route': The route object for the given path. It will be set by
   *     \Drupal\Core\Routing\UrlGenerator::generateFromRoute().
   * @param \Symfony\Component\HttpFoundation\Request $request
   *   The HttpRequest object representing the current request.
   * @param \Drupal\Core\Render\BubbleableMetadata $bubbleable_metadata
+3 −0
Original line number Diff line number Diff line
@@ -309,6 +309,9 @@ public function generateFromRoute($name, $parameters = array(), $options = array
    $name = $this->getRouteDebugMessage($name);
    $this->processRoute($name, $route, $parameters, $generated_url);
    $path = $this->getInternalPathFromRoute($name, $route, $parameters, $query_params);
    // Outbound path processors might need the route object for the path, e.g.
    // to get the path pattern.
    $options['route'] = $route;
    $path = $this->processPath($path, $options, $generated_url);

    if (!empty($options['prefix'])) {
+16 −0
Original line number Diff line number Diff line
@@ -29,3 +29,19 @@ function content_translation_enable() {
  $message = t('<a href=":settings_url">Enable translation</a> for <em>content types</em>, <em>taxonomy vocabularies</em>, <em>accounts</em>, or any other element you wish to translate.', $t_args);
  drupal_set_message($message, 'warning');
}

/**
 * @addtogroup updates-8.0.0-rc
 * @{
 */

/**
 * Rebuild the routes as the content translation routes have now new names.
 */
function content_translation_update_8001() {
  \Drupal::service('router.builder')->rebuild();
}

/**
 * @} End of "addtogroup updates-8.0.0-rc".
 */
+6 −2
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ function content_translation_help($route_name, RouteMatchInterface $route_match)
 */
function content_translation_module_implements_alter(&$implementations, $hook) {
  switch ($hook) {
    // Move some of our hook implementations to the end of the list.
    // Move our hook_entity_type_alter() implementation to the end of the list.
    case 'entity_type_alter':
      $group = $implementations['content_translation'];
      unset($implementations['content_translation']);
@@ -140,7 +140,11 @@ function content_translation_entity_type_alter(array &$entity_types) {
      if ($entity_type->hasLinkTemplate('canonical')) {
        // Provide default route names for the translation paths.
        if (!$entity_type->hasLinkTemplate('drupal:content-translation-overview')) {
          $entity_type->setLinkTemplate('drupal:content-translation-overview', $entity_type->getLinkTemplate('canonical') . '/translations');
          $translations_path = $entity_type->getLinkTemplate('canonical') . '/translations';
          $entity_type->setLinkTemplate('drupal:content-translation-overview', $translations_path);
          $entity_type->setLinkTemplate('drupal:content-translation-add', $translations_path . '/add/{source}/{target}');
          $entity_type->setLinkTemplate('drupal:content-translation-edit', $translations_path . '/edit/{language}');
          $entity_type->setLinkTemplate('drupal:content-translation-delete', $translations_path . '/delete/{language}');
        }
        // @todo Remove this as soon as menu access checks rely on the
        //   controller. See https://www.drupal.org/node/2155787.
+2 −2
Original line number Diff line number Diff line
@@ -652,7 +652,7 @@ public function entityFormSourceChange($form, FormStateInterface $form_state) {
    $source = $form_state->getValue(array('source_langcode', 'source'));

    $entity_type_id = $entity->getEntityTypeId();
    $form_state->setRedirect('content_translation.translation_add_' . $entity_type_id, array(
    $form_state->setRedirect("entity.$entity_type_id.content_translation_add", array(
      $entity_type_id => $entity->id(),
      'source' => $source,
      'target' => $form_object->getFormLangcode($form_state),
@@ -689,7 +689,7 @@ function entityFormDeleteTranslation($form, FormStateInterface $form_state) {
      $form_state->setRedirectUrl($entity->urlInfo('delete-form'));
    }
    else {
      $form_state->setRedirect('content_translation.translation_delete_' . $entity_type_id, [
      $form_state->setRedirect("entity.$entity_type_id.content_translation_delete", [
        $entity_type_id => $entity->id(),
        'language' => $form_object->getFormLangcode($form_state),
      ]);
Loading