function Url::__construct
Same name in this branch
- 11.1.x vendor/phar-io/manifest/src/values/Url.php \PharIo\Manifest\Url::__construct()
- 11.1.x vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Reference/Url.php \phpDocumentor\Reflection\DocBlock\Tags\Reference\Url::__construct()
- 11.1.x core/lib/Drupal/Core/Url.php \Drupal\Core\Url::__construct()
Parameters
array<string,mixed>|null $options:
string[]|null $protocols The protocols considered to be valid for the URL (e.g. http, https, ftp, etc.) (defaults to ['http', 'https']:
bool|null $relativeProtocol Whether to accept URL without the protocol (i.e. //example.com) (defaults to false):
string[]|null $groups:
bool|null $requireTld Whether to require the URL to include a top-level domain (defaults to false):
Overrides Constraint::__construct
File
-
vendor/
symfony/ validator/ Constraints/ Url.php, line 48
Class
- Url
- Validates that a value is a valid URL string.
Namespace
Symfony\Component\Validator\ConstraintsCode
public function __construct(?array $options = null, ?string $message = null, ?array $protocols = null, ?bool $relativeProtocol = null, ?callable $normalizer = null, ?array $groups = null, mixed $payload = null, ?bool $requireTld = null, ?string $tldMessage = null) {
parent::__construct($options, $groups, $payload);
if (null === ($options['requireTld'] ?? $requireTld)) {
trigger_deprecation('symfony/validator', '7.1', 'Not passing a value for the "requireTld" option to the Url constraint is deprecated. Its default value will change to "true".');
}
$this->message = $message ?? $this->message;
$this->protocols = $protocols ?? $this->protocols;
$this->relativeProtocol = $relativeProtocol ?? $this->relativeProtocol;
$this->normalizer = $normalizer ?? $this->normalizer;
$this->requireTld = $requireTld ?? $this->requireTld;
$this->tldMessage = $tldMessage ?? $this->tldMessage;
if (null !== $this->normalizer && !\is_callable($this->normalizer)) {
throw new InvalidArgumentException(\sprintf('The "normalizer" option must be a valid callable ("%s" given).', get_debug_type($this->normalizer)));
}
}