mirror of
https://github.com/wallabag/wallabag.git
synced 2025-01-30 23:35:06 +01:00
Use a form type for entry
This commit is contained in:
parent
78cedc2262
commit
7781faa0b0
@ -7,7 +7,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Wallabag\CoreBundle\Entity\Entry;
|
||||
use Wallabag\CoreBundle\Service\Extractor;
|
||||
use Wallabag\CoreBundle\Helper\Url;
|
||||
use Wallabag\CoreBundle\Form\Type\EntryType;
|
||||
|
||||
class EntryController extends Controller
|
||||
{
|
||||
@ -22,10 +22,7 @@ class EntryController extends Controller
|
||||
{
|
||||
$entry = new Entry($this->getUser());
|
||||
|
||||
$form = $this->createFormBuilder($entry)
|
||||
->add('url', 'url')
|
||||
->add('save', 'submit')
|
||||
->getForm();
|
||||
$form = $this->createForm(new EntryType(), $entry);
|
||||
|
||||
$form->handleRequest($request);
|
||||
|
||||
|
29
src/Wallabag/CoreBundle/Form/Type/EntryType.php
Normal file
29
src/Wallabag/CoreBundle/Form/Type/EntryType.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
namespace Wallabag\CoreBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
|
||||
|
||||
class EntryType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('url', 'url')
|
||||
->add('save', 'submit')
|
||||
;
|
||||
}
|
||||
|
||||
public function setDefaultOptions(OptionsResolverInterface $resolver)
|
||||
{
|
||||
$resolver->setDefaults(array(
|
||||
'data_class' => 'Wallabag\CoreBundle\Entity\Entry',
|
||||
));
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'entry';
|
||||
}
|
||||
}
|
@ -60,7 +60,7 @@ class EntryControllerTest extends WallabagTestCase
|
||||
$form = $crawler->filter('button[type=submit]')->form();
|
||||
|
||||
$data = array(
|
||||
'form[url]' => 'https://www.mailjet.com/blog/mailjet-zapier-integrations-made-easy/',
|
||||
'entry[url]' => 'https://www.mailjet.com/blog/mailjet-zapier-integrations-made-easy/',
|
||||
);
|
||||
|
||||
$client->submit($form, $data);
|
||||
|
Loading…
x
Reference in New Issue
Block a user