function RssResponseRelativeUrlFilter::onResponse

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/EventSubscriber/RssResponseRelativeUrlFilter.php \Drupal\Core\EventSubscriber\RssResponseRelativeUrlFilter::onResponse()
  2. 8.9.x core/lib/Drupal/Core/EventSubscriber/RssResponseRelativeUrlFilter.php \Drupal\Core\EventSubscriber\RssResponseRelativeUrlFilter::onResponse()
  3. 10 core/lib/Drupal/Core/EventSubscriber/RssResponseRelativeUrlFilter.php \Drupal\Core\EventSubscriber\RssResponseRelativeUrlFilter::onResponse()

Converts relative URLs to absolute URLs.

Parameters

\Symfony\Component\HttpKernel\Event\ResponseEvent $event: The response event.

File

core/lib/Drupal/Core/EventSubscriber/RssResponseRelativeUrlFilter.php, line 22

Class

RssResponseRelativeUrlFilter
Subscribes to filter RSS responses, to make relative URIs absolute.

Namespace

Drupal\Core\EventSubscriber

Code

public function onResponse(ResponseEvent $event) {
    // Only care about RSS responses.
    if (stripos($event->getResponse()->headers
        ->get('Content-Type', ''), 'application/rss+xml') === FALSE) {
        return;
    }
    $response = $event->getResponse();
    $response->setContent($this->transformRootRelativeUrlsToAbsolute($response->getContent(), $event->getRequest()));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.