function RssResponseCdata::onResponse

Wraps RSS descriptions in CDATA.

Parameters

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

File

core/lib/Drupal/Core/EventSubscriber/RssResponseCdata.php, line 21

Class

RssResponseCdata
Subscribes to wrap RSS descriptions in CDATA.

Namespace

Drupal\Core\EventSubscriber

Code

public function onResponse(ResponseEvent $event) : void {
    // Skip responses that are not RSS.
    if (stripos($event->getResponse()->headers
        ->get('Content-Type', ''), 'application/rss+xml') === FALSE) {
        return;
    }
    $response = $event->getResponse();
    $response->setContent($this->wrapDescriptionCdata($response->getContent()));
}

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