original_string: public function link($uri, $rel, array $attributes = [])
      {
          if (!$request = $this->requestStack->getMasterRequest()) {
              return $uri;
          }
  
          $link = new Link($rel, $uri);
          foreach ($attributes as $key => $value) {
              $link = $link->withAttribute($key, $value);
          }
  
          $linkProvider = $request->attributes->get('_links', new GenericLinkProvider());
          $request->attributes->set('_links', $linkProvider->withLink($link));
  
          return $uri;
      }
code: public function link($uri, $rel, array $attributes = [])
      {
          if (!$request = $this->requestStack->getMasterRequest()) {
              return $uri;
          }
  
          $link = new Link($rel, $uri);
          foreach ($attributes as $key => $value) {
              $link = $link->withAttribute($key, $value);
          }
  
          $linkProvider = $request->attributes->get('_links', new GenericLinkProvider());
          $request->attributes->set('_links', $linkProvider->withLink($link));
  
          return $uri;
      }
code_tokens: public function link ( $ uri , $ rel , array $ attributes = [ ] ) { if ( ! $ request = $ this -> requestStack -> getMasterRequest ( ) ) { return $ uri ; } $ link = new Link ( $ rel , $ uri ) ; foreach ( $ attributes as $ key => $ value ) { $ link = $ link -> withAttribute ( $ key , $ value ) ; } $ linkProvider = $ request -> attributes -> get ( '_links' , new GenericLinkProvider ( ) ) ; $ request -> attributes -> set ( '_links' , $ linkProvider -> withLink ( $ link ) ) ; return $ uri ; }
docstring: Adds a "Link" HTTP header.
  
  @param string $uri        The relation URI
  @param string $rel        The relation type (e.g. "preload", "prefetch", "prerender" or "dns-prefetch")
  @param array  $attributes The attributes of this link (e.g. "['as' => true]", "['pr' => 0.5]")
  
  @return string The relation URI
docstring_tokens: Adds a Link HTTP header .