diff options
Diffstat (limited to 'vendor/symfony/form/Symfony/Component/Form/Extension/Core/EventListener/FixUrlProtocolListener.php')
-rw-r--r-- | vendor/symfony/form/Symfony/Component/Form/Extension/Core/EventListener/FixUrlProtocolListener.php | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/EventListener/FixUrlProtocolListener.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/EventListener/FixUrlProtocolListener.php deleted file mode 100644 index e25dacf2..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/EventListener/FixUrlProtocolListener.php +++ /dev/null | |||
@@ -1,56 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Extension\Core\EventListener; | ||
13 | |||
14 | use Symfony\Component\Form\FormEvents; | ||
15 | use Symfony\Component\Form\FormEvent; | ||
16 | use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
17 | |||
18 | /** | ||
19 | * Adds a protocol to a URL if it doesn't already have one. | ||
20 | * | ||
21 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
22 | */ | ||
23 | class FixUrlProtocolListener implements EventSubscriberInterface | ||
24 | { | ||
25 | private $defaultProtocol; | ||
26 | |||
27 | public function __construct($defaultProtocol = 'http') | ||
28 | { | ||
29 | $this->defaultProtocol = $defaultProtocol; | ||
30 | } | ||
31 | |||
32 | public function onSubmit(FormEvent $event) | ||
33 | { | ||
34 | $data = $event->getData(); | ||
35 | |||
36 | if ($this->defaultProtocol && $data && !preg_match('~^\w+://~', $data)) { | ||
37 | $event->setData($this->defaultProtocol.'://'.$data); | ||
38 | } | ||
39 | } | ||
40 | |||
41 | /** | ||
42 | * Alias of {@link onSubmit()}. | ||
43 | * | ||
44 | * @deprecated Deprecated since version 2.3, to be removed in 3.0. Use | ||
45 | * {@link onSubmit()} instead. | ||
46 | */ | ||
47 | public function onBind(FormEvent $event) | ||
48 | { | ||
49 | $this->onSubmit($event); | ||
50 | } | ||
51 | |||
52 | public static function getSubscribedEvents() | ||
53 | { | ||
54 | return array(FormEvents::SUBMIT => 'onSubmit'); | ||
55 | } | ||
56 | } | ||