PHP Class Bolt\Canonical

- Provide a getter to get the canonical url for the current request. - Update the RequestContext with the scheme/host override from the config. Note: Updating the RequestContext also applies to the UrlGenerator.
Author: Carson Full ([email protected])
Inheritance: implements Symfony\Component\EventDispatcher\EventSubscriberInterface
Afficher le fichier Open project: bolt/bolt Class Usage Examples

Protected Properties

Свойство Type Description
$requestContext Symfony\Component\Routing\RequestContext
$requestStack Symfony\Component\HttpFoundation\RequestStack
$urlGenerator Symfony\Component\Routing\Generator\UrlGeneratorInterface

Méthodes publiques

Méthode Description
__construct ( Symfony\Component\HttpFoundation\RequestStack $requestStack, Symfony\Component\Routing\RequestContext $requestContext, Symfony\Component\Routing\Generator\UrlGeneratorInterface $urlGenerator, string | null $override = null ) Constructor.
getSubscribedEvents ( )
getUrl ( ) : string | null Returns the canonical url for the current request, or null if called outside of the request cycle.
onRequest ( GetResponseEvent $event ) Sets the scheme and host overrides (if any) on the RequestContext.

Method Details

__construct() public méthode

Constructor.
public __construct ( Symfony\Component\HttpFoundation\RequestStack $requestStack, Symfony\Component\Routing\RequestContext $requestContext, Symfony\Component\Routing\Generator\UrlGeneratorInterface $urlGenerator, string | null $override = null )
$requestStack Symfony\Component\HttpFoundation\RequestStack
$requestContext Symfony\Component\Routing\RequestContext
$urlGenerator Symfony\Component\Routing\Generator\UrlGeneratorInterface
$override string | null An optional scheme/host override.

getSubscribedEvents() public static méthode

public static getSubscribedEvents ( )

getUrl() public méthode

Returns the canonical url for the current request, or null if called outside of the request cycle.
public getUrl ( ) : string | null
Résultat string | null

onRequest() public méthode

This needs to happen after RouterListener as that sets the scheme and host from the request. To override we need to be after that.
public onRequest ( GetResponseEvent $event )
$event Symfony\Component\HttpKernel\Event\GetResponseEvent

Property Details

$requestContext protected_oe property

protected RequestContext,Symfony\Component\Routing $requestContext
Résultat Symfony\Component\Routing\RequestContext

$requestStack protected_oe property

protected RequestStack,Symfony\Component\HttpFoundation $requestStack
Résultat Symfony\Component\HttpFoundation\RequestStack

$urlGenerator protected_oe property

protected UrlGeneratorInterface,Symfony\Component\Routing\Generator $urlGenerator
Résultat Symfony\Component\Routing\Generator\UrlGeneratorInterface