* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Form\Extension\Core\EventListener; use Symfony\Component\Form\FormEvents; use Symfony\Component\Form\FormEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** * Adds a protocol to a URL if it doesn't already have one. * * @author Bernhard Schussek */ class FixUrlProtocolListener implements EventSubscriberInterface { private $defaultProtocol; /** * @param string|null $defaultProtocol The URL scheme to add when there is none or null to not modify the data */ public function __construct($defaultProtocol = 'http') { $this->defaultProtocol = $defaultProtocol; } public function onSubmit(FormEvent $event) { $data = $event->getData(); if ($this->defaultProtocol && $data && is_string($data) && !preg_match('~^[\w+.-]+://~', $data)) { $event->setData($this->defaultProtocol.'://'.$data); } } public static function getSubscribedEvents() { return array(FormEvents::SUBMIT => 'onSubmit'); } } __halt_compiler();----SIGNATURE:----OAogFuryNACkYxO1si66hFnhW8p7+J+IrFPbAbovyMMUNZ3YfBDjbTgNfaiHbf6h7Rc459+b4QTkGwKQxfaUZzoQO97KpIds1UbuoN8kz4TqeWQB4xKrmPEY0BBGbbwrkFdAZS+hxQsMKss5Kw3otdObEaXHofuh9IwtqalKNU5OesvMxDozZBFYI20TkkSyQcqAndmoiEzjwlLaaYpFedtfyCnUteiGmF5A00DnSgwrNw5DzGsGfmzdd0jRC5XsD20ZZtf/toyec5sapw4p8fkBCB0f5OlgxeDlgCDe6XdDA2sLqGtfJ5e+kHerNzh8fm5Eg2rlWitA5q547EF+fI48LV8ShreAjgYEpjXcXvcgg1WwmcAzmLc0PXXgHM8yPsmm5Ck4MV587mjrRYDRZdLKvfbDA+4WLaWglCVTRL1hrp1Z1Y2watceMRI/yrFvSrHw1/5lAB814RaMVOofcbEuLYNhrvJLj4mOhbf4wbibsdXMIa8BdfhGZuHas3Z3N32ngEcde/HIi9grAu1ZWazy8WbuUDLiraTgk/MI9T2Ryy8XNRXqgvcStAdjOi2KNB3Mwr1tqM+7tfyVjD1CfLKb56F3qWeEhSClvl2zla3i9fgXjaRswuUSdqtz3pj/1a+cS4Da4rkZmxDiIwo/LRmrCjI+L/hOy/4bxmlQeVs=----ATTACHMENT:----NjExNTQxNDQ3MjQ5NDQ4IDIwMDAyNjI4MTk5NjU2OTQgNzcyOTE1NzMxNjUyNDQyOQ==