芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/.trash/libraries.3/vendor/symfony/web-link/EventListener/AddLinkHeaderListener.php
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\WebLink\EventListener; use Psr\Link\LinkProviderInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpKernel\Event\ResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\WebLink\HttpHeaderSerializer; // Help opcache.preload discover always-needed symbols class_exists(HttpHeaderSerializer::class); /** * Adds the Link HTTP header to the response. * * @author Kévin Dunglas
* * @final */ class AddLinkHeaderListener implements EventSubscriberInterface { private $serializer; public function __construct() { $this->serializer = new HttpHeaderSerializer(); } public function onKernelResponse(ResponseEvent $event) { if (!$event->isMainRequest()) { return; } $linkProvider = $event->getRequest()->attributes->get('_links'); if (!$linkProvider instanceof LinkProviderInterface || !$links = $linkProvider->getLinks()) { return; } $event->getResponse()->headers->set('Link', $this->serializer->serialize($links), false); } /** * {@inheritdoc} */ public static function getSubscribedEvents(): array { return [KernelEvents::RESPONSE => 'onKernelResponse']; } }