You are here

public function ExternalHreflangGetCurrentUrlEventSubscriber::onGetCurrentUrlEvent in External Hreflang 8

Default implementation of getting current page url.

Parameters

\Drupal\external_hreflang\Event\ExternalHreflangGetCurrentUrlEvent $event: Event object.

File

src/EventSubscriber/ExternalHreflangGetCurrentUrlEventSubscriber.php, line 63

Class

ExternalHreflangGetCurrentUrlEventSubscriber
Subscriber for ExternalHreflangGetCurrentUrlEvent.

Namespace

Drupal\external_hreflang\EventSubscriber

Code

public function onGetCurrentUrlEvent(ExternalHreflangGetCurrentUrlEvent $event) {
  if ($this->pathMatcher
    ->isFrontPage()) {
    $url = Url::fromRoute('<front>');
  }
  else {
    $url = Url::createFromRequest($this->requestStack
      ->getCurrentRequest());
  }
  $event
    ->setCurrentUrl($url);
}