I have the following code;
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add(
$builder->create(
'href',
'url',
$this->getOptionsForUrlWidget('Website URL')
)->addEventSubscriber(new GetResolvedUrlListener())
)
...
My method GetResolvedUrlListener
does a curl request to discover the correct protocol and final address (following redirects) to determine the correct url.
I would like it to cause validation to fail if the curl request does not receive a successful HTTP response. So if the supplied url is not reachable, it should not save.
Can this be done in a class that implements the EventSubscriberInterface? Should I rather add a new constraint and validate the supplied url twice?