forked from wallabag/wallabag
Enhance documentation and create a form to create a new client
This commit is contained in:
committed by
Nicolas Lœuillet
parent
6a2c524a2c
commit
abc329453b
44
src/Wallabag/CoreBundle/Form/Type/ClientType.php
Normal file
44
src/Wallabag/CoreBundle/Form/Type/ClientType.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Wallabag\CoreBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\CallbackTransformer;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\UrlType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class ClientType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('redirect_uris', UrlType::class, array('required' => true))
|
||||
->add('save', SubmitType::class)
|
||||
;
|
||||
|
||||
$builder->get('redirect_uris')
|
||||
->addModelTransformer(new CallbackTransformer(
|
||||
function ($originalUri) {
|
||||
return $originalUri;
|
||||
},
|
||||
function ($submittedUri) {
|
||||
return array($submittedUri);
|
||||
}
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults(array(
|
||||
'data_class' => 'Wallabag\ApiBundle\Entity\Client',
|
||||
));
|
||||
}
|
||||
|
||||
public function getBlockPrefix()
|
||||
{
|
||||
return 'client';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user