aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorJeremy <jeremy.benoist@gmail.com>2015-02-16 21:31:42 +0100
committerJeremy <jeremy.benoist@gmail.com>2015-02-16 21:31:58 +0100
commit7781faa0b0749b0d9842fddec3e337db04d44a10 (patch)
tree7f7d418cff4a44626b170df092f330777501ac70 /src
parent78cedc2262fa6d13904915cacd546389d3f453fc (diff)
downloadwallabag-7781faa0b0749b0d9842fddec3e337db04d44a10.tar.gz
wallabag-7781faa0b0749b0d9842fddec3e337db04d44a10.tar.zst
wallabag-7781faa0b0749b0d9842fddec3e337db04d44a10.zip
Use a form type for entry
Diffstat (limited to 'src')
-rw-r--r--src/Wallabag/CoreBundle/Controller/EntryController.php7
-rw-r--r--src/Wallabag/CoreBundle/Form/Type/EntryType.php29
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php2
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;
7use Symfony\Component\HttpFoundation\Request; 7use Symfony\Component\HttpFoundation\Request;
8use Wallabag\CoreBundle\Entity\Entry; 8use Wallabag\CoreBundle\Entity\Entry;
9use Wallabag\CoreBundle\Service\Extractor; 9use Wallabag\CoreBundle\Service\Extractor;
10use Wallabag\CoreBundle\Helper\Url; 10use Wallabag\CoreBundle\Form\Type\EntryType;
11 11
12class EntryController extends Controller 12class 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
2namespace Wallabag\CoreBundle\Form\Type;
3
4use Symfony\Component\Form\AbstractType;
5use Symfony\Component\Form\FormBuilderInterface;
6use Symfony\Component\OptionsResolver\OptionsResolverInterface;
7
8class 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);