class OEmbedResourceConstraintValidator extends ConstraintValidator implements ContainerInjectionInterface (View source)

internal  This is an internal part of the oEmbed system and should only be used by oEmbed-related code in Drupal core.
 

Validates oEmbed resource URLs.

Properties

protected UrlResolverInterface $urlResolver

The oEmbed URL resolver service.

protected ResourceFetcherInterface $resourceFetcher

The resource fetcher service.

protected LoggerChannelInterface $logger

The logger service.

Methods

__construct(UrlResolverInterface $url_resolver, ResourceFetcherInterface $resource_fetcher, LoggerChannelFactoryInterface $logger_factory)

Constructs a new OEmbedResourceConstraintValidator.

static 
create(ContainerInterface $container)

Instantiates a new instance of this class.

validate($value, Constraint $constraint)

{@inheritdoc}

handleException(Exception $e, string $error_message = NULL)

Handles exceptions that occur during validation.

Details

__construct(UrlResolverInterface $url_resolver, ResourceFetcherInterface $resource_fetcher, LoggerChannelFactoryInterface $logger_factory)

Constructs a new OEmbedResourceConstraintValidator.

Parameters

UrlResolverInterface $url_resolver

The oEmbed URL resolver service.

ResourceFetcherInterface $resource_fetcher

The resource fetcher service.

LoggerChannelFactoryInterface $logger_factory

The logger service.

static create(ContainerInterface $container)

Instantiates a new instance of this class.

This is a factory method that returns a new instance of this class. The factory should pass any needed dependencies into the constructor of this class, but not the container itself. Every call to this method must return a new instance of this class; that is, it may not implement a singleton.

Parameters

ContainerInterface $container

The service container this instance should use.

validate($value, Constraint $constraint)

{@inheritdoc}

Parameters

$value
Constraint $constraint

protected handleException(Exception $e, string $error_message = NULL)

Handles exceptions that occur during validation.

Parameters

Exception $e

The caught exception.

string $error_message

(optional) The error message to set as a constraint violation.