2015-10-11 15:30:58 +00:00
|
|
|
<?php
|
|
|
|
|
2024-02-19 00:30:12 +00:00
|
|
|
namespace Wallabag\Form\Type;
|
2015-10-11 15:30:58 +00:00
|
|
|
|
|
|
|
use Symfony\Component\Form\AbstractType;
|
2015-12-22 09:16:34 +00:00
|
|
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
|
|
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
2015-10-11 15:30:58 +00:00
|
|
|
use Symfony\Component\Form\FormBuilderInterface;
|
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
2024-02-19 00:30:12 +00:00
|
|
|
use Wallabag\Entity\TaggingRule;
|
|
|
|
use Wallabag\Form\DataTransformer\StringToListTransformer;
|
2015-10-11 15:30:58 +00:00
|
|
|
|
|
|
|
class TaggingRuleType extends AbstractType
|
|
|
|
{
|
|
|
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
|
|
|
{
|
|
|
|
$builder
|
2016-04-12 09:36:01 +00:00
|
|
|
->add('rule', TextType::class, [
|
2016-03-09 07:59:08 +00:00
|
|
|
'required' => true,
|
|
|
|
'label' => 'config.form_rules.rule_label',
|
2016-04-12 09:36:01 +00:00
|
|
|
])
|
|
|
|
->add('save', SubmitType::class, [
|
2016-03-09 07:59:08 +00:00
|
|
|
'label' => 'config.form.save',
|
2016-04-12 09:36:01 +00:00
|
|
|
])
|
2015-10-11 15:30:58 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
$tagsField = $builder
|
2016-04-12 09:36:01 +00:00
|
|
|
->create('tags', TextType::class, [
|
2016-03-09 07:59:08 +00:00
|
|
|
'label' => 'config.form_rules.tags_label',
|
2016-04-12 09:36:01 +00:00
|
|
|
])
|
2015-10-11 15:30:58 +00:00
|
|
|
->addModelTransformer(new StringToListTransformer(','));
|
|
|
|
|
|
|
|
$builder->add($tagsField);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function configureOptions(OptionsResolver $resolver)
|
|
|
|
{
|
2016-04-12 09:36:01 +00:00
|
|
|
$resolver->setDefaults([
|
2022-09-01 18:54:56 +00:00
|
|
|
'data_class' => TaggingRule::class,
|
2016-04-12 09:36:01 +00:00
|
|
|
]);
|
2015-10-11 15:30:58 +00:00
|
|
|
}
|
|
|
|
|
2015-12-22 09:16:34 +00:00
|
|
|
public function getBlockPrefix()
|
2015-10-11 15:30:58 +00:00
|
|
|
{
|
|
|
|
return 'tagging_rule';
|
|
|
|
}
|
|
|
|
}
|