original_string: public function generateUri($request, $path)
      {
          if (0 === strpos($path, 'http') || !$path) {
              return $path;
          }
  
          if ('/' === $path[0]) {
              return $request->getUriForPath($path);
          }
  
          if (null === $this->urlGenerator) {
              throw new \LogicException('You must provide a UrlGeneratorInterface instance to be able to use routes.');
          }
  
          $url = $this->urlGenerator->generate($path, $request->attributes->all(), UrlGeneratorInterface::ABSOLUTE_URL);
  
          // unnecessary query string parameters must be removed from URL
          // (ie. query parameters that are presents in $attributes)
          // fortunately, they all are, so we have to remove entire query string
          $position = strpos($url, '?');
          if (false !== $position) {
              $fragment = parse_url($url, PHP_URL_FRAGMENT);
              $url = substr($url, 0, $position);
              // fragment must be preserved
              if ($fragment) {
                  $url .= "#$fragment";
              }
          }
  
          return $url;
      }
code: public function generateUri($request, $path)
      {
          if (0 === strpos($path, 'http') || !$path) {
              return $path;
          }
  
          if ('/' === $path[0]) {
              return $request->getUriForPath($path);
          }
  
          if (null === $this->urlGenerator) {
              throw new \LogicException('You must provide a UrlGeneratorInterface instance to be able to use routes.');
          }
  
          $url = $this->urlGenerator->generate($path, $request->attributes->all(), UrlGeneratorInterface::ABSOLUTE_URL);
  
          // unnecessary query string parameters must be removed from URL
          // (ie. query parameters that are presents in $attributes)
          // fortunately, they all are, so we have to remove entire query string
          $position = strpos($url, '?');
          if (false !== $position) {
              $fragment = parse_url($url, PHP_URL_FRAGMENT);
              $url = substr($url, 0, $position);
              // fragment must be preserved
              if ($fragment) {
                  $url .= "#$fragment";
              }
          }
  
          return $url;
      }
code_tokens: public function generateUri ( $ request , $ path ) { if ( 0 === strpos ( $ path , 'http' ) || ! $ path ) { return $ path ; } if ( '/' === $ path [ 0 ] ) { return $ request -> getUriForPath ( $ path ) ; } if ( null === $ this -> urlGenerator ) { throw new \ LogicException ( 'You must provide a UrlGeneratorInterface instance to be able to use routes.' ) ; } $ url = $ this -> urlGenerator -> generate ( $ path , $ request -> attributes -> all ( ) , UrlGeneratorInterface :: ABSOLUTE_URL ) ; // unnecessary query string parameters must be removed from URL // (ie. query parameters that are presents in $attributes) // fortunately, they all are, so we have to remove entire query string $ position = strpos ( $ url , '?' ) ; if ( false !== $ position ) { $ fragment = parse_url ( $ url , PHP_URL_FRAGMENT ) ; $ url = substr ( $ url , 0 , $ position ) ; // fragment must be preserved if ( $ fragment ) { $ url .= "#$fragment" ; } } return $ url ; }
docstring: Generates a URI, based on the given path or absolute URL.
  
  @param Request $request A Request instance
  @param string  $path    A path (an absolute path (/foo), an absolute URL (http://...), or a route name (foo))
  
  @return string An absolute URL
  
  @throws \LogicException
docstring_tokens: Generates a URI based on the given path or absolute URL .