src/Hydra/EventListener/AddLinkHeaderListener.php
public function onKernelResponse(FilterResponseEvent $event): void
    {
        $apiDocUrl = $this->urlGenerator->generate('api_doc', ['_format' => 'jsonld'], UrlGeneratorInterface::ABS_URL);
        $link = new Link(ContextBuilder::HYDRA_NS.'apiDocumentation', $apiDocUrl);

        $attributes = $event->getRequest()->attributes;
        if (null === $linkProvider = $attributes->get('_links')) {
            $attributes->set('_links', new GenericLinkProvider([$link]));

            return;
        }
        $attributes->set('_links', $linkProvider->withLink($link));
    }
public function onKernelResponse(FilterResponseEvent $event): void
    {
        $apiDocUrl = $this->urlGenerator->generate('api_doc', ['_format' => 'jsonld'], UrlGeneratorInterface::ABS_URL);
        $link = new Link(ContextBuilder::HYDRA_NS.'apiDocumentation', $apiDocUrl);

        $attributes = $event->getRequest()->attributes;
        if (null === $linkProvider = $attributes->get('_links')) {
            $attributes->set('_links', new GenericLinkProvider([$link]));

            return;
        }
        $attributes->set('_links', $linkProvider->withLink($link));
    }
public function onKernelResponse ( FilterResponseEvent $ event ) : void { $ apiDocUrl = $ this -> urlGenerator -> generate ( 'api_doc' , [ '_format' => 'jsonld' ] , UrlGeneratorInterface :: ABS_URL ) ; $ link = new Link ( ContextBuilder :: HYDRA_NS . 'apiDocumentation' , $ apiDocUrl ) ; $ attributes = $ event -> getRequest ( ) -> attributes ; if ( null === $ linkProvider = $ attributes -> get ( '_links' ) ) { $ attributes -> set ( '_links' , new GenericLinkProvider ( [ $ link ] ) ) ; return ; } $ attributes -> set ( '_links' , $ linkProvider -> withLink ( $ link ) ) ; }
Sends the Hydra header on each response.
Sends the Hydra header on each response .