diff options
author | Jeremy <jeremy.benoist@gmail.com> | 2015-02-16 21:31:42 +0100 |
---|---|---|
committer | Jeremy <jeremy.benoist@gmail.com> | 2015-02-16 21:31:58 +0100 |
commit | 7781faa0b0749b0d9842fddec3e337db04d44a10 (patch) | |
tree | 7f7d418cff4a44626b170df092f330777501ac70 /src/Wallabag/CoreBundle | |
parent | 78cedc2262fa6d13904915cacd546389d3f453fc (diff) | |
download | wallabag-7781faa0b0749b0d9842fddec3e337db04d44a10.tar.gz wallabag-7781faa0b0749b0d9842fddec3e337db04d44a10.tar.zst wallabag-7781faa0b0749b0d9842fddec3e337db04d44a10.zip |
Use a form type for entry
Diffstat (limited to 'src/Wallabag/CoreBundle')
3 files changed, 32 insertions, 6 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php index 89677bef..81ab7788 100644 --- a/src/Wallabag/CoreBundle/Controller/EntryController.php +++ b/src/Wallabag/CoreBundle/Controller/EntryController.php | |||
@@ -7,7 +7,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller; | |||
7 | use Symfony\Component\HttpFoundation\Request; | 7 | use Symfony\Component\HttpFoundation\Request; |
8 | use Wallabag\CoreBundle\Entity\Entry; | 8 | use Wallabag\CoreBundle\Entity\Entry; |
9 | use Wallabag\CoreBundle\Service\Extractor; | 9 | use Wallabag\CoreBundle\Service\Extractor; |
10 | use Wallabag\CoreBundle\Helper\Url; | 10 | use Wallabag\CoreBundle\Form\Type\EntryType; |
11 | 11 | ||
12 | class EntryController extends Controller | 12 | class EntryController extends Controller |
13 | { | 13 | { |
@@ -22,10 +22,7 @@ class EntryController extends Controller | |||
22 | { | 22 | { |
23 | $entry = new Entry($this->getUser()); | 23 | $entry = new Entry($this->getUser()); |
24 | 24 | ||
25 | $form = $this->createFormBuilder($entry) | 25 | $form = $this->createForm(new EntryType(), $entry); |
26 | ->add('url', 'url') | ||
27 | ->add('save', 'submit') | ||
28 | ->getForm(); | ||
29 | 26 | ||
30 | $form->handleRequest($request); | 27 | $form->handleRequest($request); |
31 | 28 | ||
diff --git a/src/Wallabag/CoreBundle/Form/Type/EntryType.php b/src/Wallabag/CoreBundle/Form/Type/EntryType.php new file mode 100644 index 00000000..cfd64473 --- /dev/null +++ b/src/Wallabag/CoreBundle/Form/Type/EntryType.php | |||
@@ -0,0 +1,29 @@ | |||
1 | <?php | ||
2 | namespace Wallabag\CoreBundle\Form\Type; | ||
3 | |||
4 | use Symfony\Component\Form\AbstractType; | ||
5 | use Symfony\Component\Form\FormBuilderInterface; | ||
6 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
7 | |||
8 | class EntryType extends AbstractType | ||
9 | { | ||
10 | public function buildForm(FormBuilderInterface $builder, array $options) | ||
11 | { | ||
12 | $builder | ||
13 | ->add('url', 'url') | ||
14 | ->add('save', 'submit') | ||
15 | ; | ||
16 | } | ||
17 | |||
18 | public function setDefaultOptions(OptionsResolverInterface $resolver) | ||
19 | { | ||
20 | $resolver->setDefaults(array( | ||
21 | 'data_class' => 'Wallabag\CoreBundle\Entity\Entry', | ||
22 | )); | ||
23 | } | ||
24 | |||
25 | public function getName() | ||
26 | { | ||
27 | return 'entry'; | ||
28 | } | ||
29 | } | ||
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php index 7276f8e4..2634141e 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php | |||
@@ -60,7 +60,7 @@ class EntryControllerTest extends WallabagTestCase | |||
60 | $form = $crawler->filter('button[type=submit]')->form(); | 60 | $form = $crawler->filter('button[type=submit]')->form(); |
61 | 61 | ||
62 | $data = array( | 62 | $data = array( |
63 | 'form[url]' => 'https://www.mailjet.com/blog/mailjet-zapier-integrations-made-easy/', | 63 | 'entry[url]' => 'https://www.mailjet.com/blog/mailjet-zapier-integrations-made-easy/', |
64 | ); | 64 | ); |
65 | 65 | ||
66 | $client->submit($form, $data); | 66 | $client->submit($form, $data); |