Skip to content

Commit

Permalink
Merge pull request #75 from aleevas/DS-1471
Browse files Browse the repository at this point in the history
feat: [DS-1471] Move back fix for redirect to avoid redirecting for cached cripts and styles
  • Loading branch information
podarok authored Jun 10, 2024
2 parents dd69bde + 0bbf3b0 commit b6f39a5
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions openy_system/src/EventSubscriber/TermsSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace Drupal\openy_system\EventSubscriber;

use Drupal\Core\Url;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\KernelEvents;

/**
* Class TermsSubscriber.
Expand All @@ -28,7 +28,12 @@ class TermsSubscriber implements EventSubscriberInterface {
protected $currentUser;

/**
* Constructs a new TermsSubscriber event subscriber.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* * The configuration factory.
* @param \Drupal\Core\Session\AccountInterface $current_user
* The current logged user.
*/
public function __construct(ConfigFactoryInterface $config_factory, AccountInterface $current_user) {
$this->config = $config_factory->get('openy.terms_and_conditions.schema');
Expand All @@ -39,6 +44,12 @@ public function __construct(ConfigFactoryInterface $config_factory, AccountInter
* {@inheritdoc}
*/
public function checkForRedirection(RequestEvent $event) {
$request = clone $event->getRequest();
// See https://www.drupal.org/project/redirect/issues/3373123 .
if ($request->attributes->get('_disable_route_normalizer')) {
return;
}

$url = Url::fromRoute('openy_system.openy_terms_and_conditions')
->toString();
$request_uri = $event->getRequest()->getRequestUri();
Expand Down

0 comments on commit b6f39a5

Please sign in to comment.