Commit f83734b8 authored by Binny Thomas's avatar Binny Thomas Committed by Binny Thomas
Browse files

Issue #3310784 by binnythomas: Making the controller params optional

parent c9fd0939
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -90,8 +90,6 @@ class UberAffiliate extends ControllerBase {





    $affid =  (int) Xss::filter($aff_id);
    $path_given = $dest_path;
    $tracker = (int) Xss::filter($tracker_id);
@@ -140,11 +138,17 @@ class UberAffiliate extends ControllerBase {
    }

    // Unnecessary check_url()? Better safe than sorry...
    $destination_actual = check_url($destination_actual);
    $destination_actual =  UrlHelper::stripDangerousProtocols($destination_actual);

    // At minimum, if all validations fail, we'll be taken to the front page. If the path
    // given is valid though, we'll be taken to that path either way, regardless of whether
    // the affiliate was credited with a valid click-thru.
    if (empty($destination_actual)) {
      $language = \Drupal::languageManager()->getLanguage('vi');
      $url = Url::fromRoute('<front>', [], ['language' => $language]);
      return new RedirectResponse($url->toString());

    }
    return new RedirectResponse(\Drupal\Core\Url::fromRoute($destination_actual)->toString());
  }
}
+2 −0
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@ class AffiliateRoute {
      $affiliate_menu_path . '/' .   '{aff_id}' . '/' . '{dest_path}' . '/' . '{tracker_id}',
      [
        '_controller' => 'Drupal\uber_affiliate\Controller\UberAffiliate::affiliate_page',
        'dest_path' => 'fallback',
        'tracker_id' => 'fallback',
      ],
      [
        '_permission'  => 'track affiliate clicks for this role',