mirror of
https://github.com/wallabag/wallabag.git
synced 2025-08-26 18:21:02 +00:00
Move source files directly under src/ directory
This commit is contained in:
parent
804261bc26
commit
a37b385c23
190 changed files with 19 additions and 21 deletions
57
src/Form/DataTransformer/StringToListTransformer.php
Normal file
57
src/Form/DataTransformer/StringToListTransformer.php
Normal file
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\CoreBundle\Form\DataTransformer;
|
||||
|
||||
use Symfony\Component\Form\DataTransformerInterface;
|
||||
|
||||
/**
|
||||
* Transforms a comma-separated list to a proper PHP array.
|
||||
* Example: the string "foo, bar" will become the array ["foo", "bar"].
|
||||
*/
|
||||
class StringToListTransformer implements DataTransformerInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $separator;
|
||||
|
||||
/**
|
||||
* @param string $separator The separator used in the list
|
||||
*/
|
||||
public function __construct($separator = ',')
|
||||
{
|
||||
$this->separator = $separator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms a list to a string.
|
||||
*
|
||||
* @param array|null $list
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function transform($list)
|
||||
{
|
||||
if (null === $list) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return implode($this->separator, $list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms a string to a list.
|
||||
*
|
||||
* @param string $string
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public function reverseTransform($string)
|
||||
{
|
||||
if (null === $string) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return array_values(array_filter(array_map('trim', explode($this->separator, $string))));
|
||||
}
|
||||
}
|
52
src/Form/Type/Api/ClientType.php
Normal file
52
src/Form/Type/Api/ClientType.php
Normal file
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\CoreBundle\Form\Type\Api;
|
||||
|
||||
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\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\UrlType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Wallabag\CoreBundle\Entity\Api\Client;
|
||||
|
||||
class ClientType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('name', TextType::class, ['label' => 'developer.client.form.name_label'])
|
||||
->add('redirect_uris', UrlType::class, [
|
||||
'required' => false,
|
||||
'label' => 'developer.client.form.redirect_uris_label',
|
||||
'property_path' => 'redirectUris',
|
||||
'default_protocol' => null,
|
||||
])
|
||||
->add('save', SubmitType::class, ['label' => 'developer.client.form.save_label'])
|
||||
;
|
||||
|
||||
$builder->get('redirect_uris')
|
||||
->addModelTransformer(new CallbackTransformer(
|
||||
function ($originalUri) {
|
||||
return $originalUri;
|
||||
},
|
||||
function ($submittedUri) {
|
||||
return [$submittedUri];
|
||||
}
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Client::class,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getBlockPrefix()
|
||||
{
|
||||
return 'client';
|
||||
}
|
||||
}
|
48
src/Form/Type/ChangePasswordType.php
Normal file
48
src/Form/Type/ChangePasswordType.php
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\CoreBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Security\Core\Validator\Constraints\UserPassword;
|
||||
use Symfony\Component\Validator\Constraints\Length;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
|
||||
class ChangePasswordType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('old_password', PasswordType::class, [
|
||||
'constraints' => new UserPassword(['message' => 'validator.password_wrong_value']),
|
||||
'label' => 'config.form_password.old_password_label',
|
||||
])
|
||||
->add('new_password', RepeatedType::class, [
|
||||
'type' => PasswordType::class,
|
||||
'invalid_message' => 'validator.password_must_match',
|
||||
'required' => true,
|
||||
'first_options' => ['label' => 'config.form_password.new_password_label'],
|
||||
'second_options' => ['label' => 'config.form_password.repeat_new_password_label'],
|
||||
'constraints' => [
|
||||
new Length([
|
||||
'min' => 8,
|
||||
'minMessage' => 'validator.password_too_short',
|
||||
]),
|
||||
new NotBlank(),
|
||||
],
|
||||
'label' => 'config.form_password.new_password_label',
|
||||
])
|
||||
->add('save', SubmitType::class, [
|
||||
'label' => 'config.form.save',
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function getBlockPrefix()
|
||||
{
|
||||
return 'change_passwd';
|
||||
}
|
||||
}
|
127
src/Form/Type/ConfigType.php
Normal file
127
src/Form/Type/ConfigType.php
Normal file
|
@ -0,0 +1,127 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\CoreBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\RangeType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Wallabag\CoreBundle\Entity\Config;
|
||||
|
||||
class ConfigType extends AbstractType
|
||||
{
|
||||
private $languages = [];
|
||||
private $fonts = [];
|
||||
|
||||
/**
|
||||
* @param array $languages Languages come from configuration, array just code language as key and label as value
|
||||
* @param array $fonts Fonts come from configuration, array just font name as key / value
|
||||
*/
|
||||
public function __construct($languages, $fonts)
|
||||
{
|
||||
$this->languages = $languages;
|
||||
$this->fonts = $fonts;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('font', ChoiceType::class, [
|
||||
'choices' => $this->initFonts(),
|
||||
'label' => 'config.form_settings.font_label',
|
||||
'property_path' => 'font',
|
||||
])
|
||||
->add('fontsize', RangeType::class, [
|
||||
'attr' => [
|
||||
'min' => 0.6,
|
||||
'max' => 2,
|
||||
'step' => 0.1,
|
||||
],
|
||||
'label' => 'config.form_settings.fontsize_label',
|
||||
'property_path' => 'fontsize',
|
||||
])
|
||||
->add('lineHeight', RangeType::class, [
|
||||
'attr' => [
|
||||
'min' => 0.6,
|
||||
'max' => 2,
|
||||
'step' => 0.1,
|
||||
],
|
||||
'label' => 'config.form_settings.lineheight_label',
|
||||
'property_path' => 'lineHeight',
|
||||
])
|
||||
->add('maxWidth', RangeType::class, [
|
||||
'attr' => [
|
||||
'min' => 20,
|
||||
'max' => 60,
|
||||
'step' => 5,
|
||||
],
|
||||
'label' => 'config.form_settings.maxwidth_label',
|
||||
'property_path' => 'maxWidth',
|
||||
])
|
||||
->add('items_per_page', IntegerType::class, [
|
||||
'label' => 'config.form_settings.items_per_page_label',
|
||||
'property_path' => 'itemsPerPage',
|
||||
])
|
||||
->add('display_thumbnails', CheckboxType::class, [
|
||||
'label' => 'config.form_settings.display_thumbnails_label',
|
||||
'property_path' => 'displayThumbnails',
|
||||
'required' => false,
|
||||
])
|
||||
->add('reading_speed', IntegerType::class, [
|
||||
'label' => 'config.form_settings.reading_speed.label',
|
||||
'property_path' => 'readingSpeed',
|
||||
])
|
||||
->add('action_mark_as_read', ChoiceType::class, [
|
||||
'label' => 'config.form_settings.action_mark_as_read.label',
|
||||
'property_path' => 'actionMarkAsRead',
|
||||
'choices' => [
|
||||
'config.form_settings.action_mark_as_read.redirect_homepage' => Config::REDIRECT_TO_HOMEPAGE,
|
||||
'config.form_settings.action_mark_as_read.redirect_current_page' => Config::REDIRECT_TO_CURRENT_PAGE,
|
||||
],
|
||||
])
|
||||
->add('language', ChoiceType::class, [
|
||||
'choices' => array_flip($this->languages),
|
||||
'label' => 'config.form_settings.language_label',
|
||||
])
|
||||
->add('pocket_consumer_key', null, [
|
||||
'property_path' => 'pocketConsumerKey',
|
||||
'label' => 'config.form_settings.pocket_consumer_key_label',
|
||||
])
|
||||
->add('save', SubmitType::class, [
|
||||
'label' => 'config.form.save',
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Config::class,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getBlockPrefix()
|
||||
{
|
||||
return 'config';
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an array with font name as key / value.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function initFonts()
|
||||
{
|
||||
$fonts = [];
|
||||
|
||||
foreach ($this->fonts as $font) {
|
||||
$fonts[$font] = $font;
|
||||
}
|
||||
|
||||
return $fonts;
|
||||
}
|
||||
}
|
18
src/Form/Type/EditAnnotationType.php
Normal file
18
src/Form/Type/EditAnnotationType.php
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\CoreBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
class EditAnnotationType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('text', null, [
|
||||
'empty_data' => '',
|
||||
])
|
||||
;
|
||||
}
|
||||
}
|
51
src/Form/Type/EditEntryType.php
Normal file
51
src/Form/Type/EditEntryType.php
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\CoreBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\UrlType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Wallabag\CoreBundle\Entity\Entry;
|
||||
|
||||
class EditEntryType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('title', TextType::class, [
|
||||
'required' => true,
|
||||
'label' => 'entry.edit.title_label',
|
||||
])
|
||||
->add('url', UrlType::class, [
|
||||
'disabled' => true,
|
||||
'required' => false,
|
||||
'label' => 'entry.edit.url_label',
|
||||
'default_protocol' => null,
|
||||
])
|
||||
->add('origin_url', UrlType::class, [
|
||||
'required' => false,
|
||||
'property_path' => 'originUrl',
|
||||
'label' => 'entry.edit.origin_url_label',
|
||||
'default_protocol' => null,
|
||||
])
|
||||
->add('save', SubmitType::class, [
|
||||
'label' => 'entry.edit.save_label',
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Entry::class,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getBlockPrefix()
|
||||
{
|
||||
return 'entry';
|
||||
}
|
||||
}
|
217
src/Form/Type/EntryFilterType.php
Normal file
217
src/Form/Type/EntryFilterType.php
Normal file
|
@ -0,0 +1,217 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\CoreBundle\Form\Type;
|
||||
|
||||
use Spiriit\Bundle\FormFilterBundle\Filter\FilterOperands;
|
||||
use Spiriit\Bundle\FormFilterBundle\Filter\Form\Type\CheckboxFilterType;
|
||||
use Spiriit\Bundle\FormFilterBundle\Filter\Form\Type\ChoiceFilterType;
|
||||
use Spiriit\Bundle\FormFilterBundle\Filter\Form\Type\DateRangeFilterType;
|
||||
use Spiriit\Bundle\FormFilterBundle\Filter\Form\Type\NumberFilterType;
|
||||
use Spiriit\Bundle\FormFilterBundle\Filter\Form\Type\NumberRangeFilterType;
|
||||
use Spiriit\Bundle\FormFilterBundle\Filter\Form\Type\TextFilterType;
|
||||
use Spiriit\Bundle\FormFilterBundle\Filter\Query\QueryInterface;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Wallabag\CoreBundle\Entity\User;
|
||||
use Wallabag\CoreBundle\Repository\EntryRepository;
|
||||
|
||||
class EntryFilterType extends AbstractType
|
||||
{
|
||||
private $repository;
|
||||
private $tokenStorage;
|
||||
|
||||
/**
|
||||
* Repository & user are used to get a list of language entries for this user.
|
||||
*/
|
||||
public function __construct(EntryRepository $entryRepository, TokenStorageInterface $tokenStorage)
|
||||
{
|
||||
$this->repository = $entryRepository;
|
||||
$this->tokenStorage = $tokenStorage;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null;
|
||||
|
||||
\assert($user instanceof User);
|
||||
|
||||
$builder
|
||||
->add('readingTime', NumberRangeFilterType::class, [
|
||||
'left_number_options' => [
|
||||
'condition_operator' => FilterOperands::OPERATOR_GREATER_THAN_EQUAL,
|
||||
'attr' => ['min' => 0],
|
||||
],
|
||||
'right_number_options' => [
|
||||
'condition_operator' => FilterOperands::OPERATOR_LOWER_THAN_EQUAL,
|
||||
'attr' => ['min' => 0],
|
||||
],
|
||||
'apply_filter' => function (QueryInterface $filterQuery, $field, $values) use ($user) {
|
||||
$lower = $values['value']['left_number'][0];
|
||||
$upper = $values['value']['right_number'][0];
|
||||
|
||||
if (null === $lower && null === $upper) {
|
||||
// no value? no filter
|
||||
return;
|
||||
}
|
||||
|
||||
$min = (int) ($lower * $user->getConfig()->getReadingSpeed() / 200);
|
||||
$max = (int) ($upper * $user->getConfig()->getReadingSpeed() / 200);
|
||||
|
||||
if (null === $lower && null !== $upper) {
|
||||
// only lower value is defined: query all entries with reading LOWER THAN this value
|
||||
$expression = $filterQuery->getExpr()->lte($field, $max);
|
||||
} elseif (null !== $lower && null === $upper) {
|
||||
// only upper value is defined: query all entries with reading GREATER THAN this value
|
||||
$expression = $filterQuery->getExpr()->gte($field, $min);
|
||||
} else {
|
||||
// both value are defined, perform a between
|
||||
$expression = $filterQuery->getExpr()->between($field, $min, $max);
|
||||
}
|
||||
|
||||
return $filterQuery->createCondition($expression);
|
||||
},
|
||||
'label' => 'entry.filters.reading_time.label',
|
||||
])
|
||||
->add('createdAt', DateRangeFilterType::class, [
|
||||
'left_date_options' => [
|
||||
'attr' => [
|
||||
'placeholder' => 'yyyy-mm-dd',
|
||||
],
|
||||
'format' => 'yyyy-MM-dd',
|
||||
'widget' => 'single_text',
|
||||
],
|
||||
'right_date_options' => [
|
||||
'attr' => [
|
||||
'placeholder' => 'yyyy-mm-dd',
|
||||
],
|
||||
'format' => 'yyyy-MM-dd',
|
||||
'widget' => 'single_text',
|
||||
],
|
||||
'label' => 'entry.filters.created_at.label',
|
||||
])
|
||||
->add('domainName', TextFilterType::class, [
|
||||
'apply_filter' => function (QueryInterface $filterQuery, $field, $values) {
|
||||
$value = $values['value'];
|
||||
if (empty($value) || \strlen($value) <= 2) {
|
||||
return false;
|
||||
}
|
||||
$expression = $filterQuery->getExpr()->like($field, $filterQuery->getExpr()->lower($filterQuery->getExpr()->literal('%' . $value . '%')));
|
||||
|
||||
return $filterQuery->createCondition($expression);
|
||||
},
|
||||
'label' => 'entry.filters.domain_label',
|
||||
'attr' => [
|
||||
'autocapitalize' => 'off',
|
||||
],
|
||||
])
|
||||
->add('httpStatus', NumberFilterType::class, [
|
||||
'apply_filter' => function (QueryInterface $filterQuery, $field, $values) {
|
||||
$value = (int) $values['value'];
|
||||
if (false === \array_key_exists($value, Response::$statusTexts)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$paramName = sprintf('%s', str_replace('.', '_', $field));
|
||||
$expression = $filterQuery->getExpr()->eq($field, ':' . $paramName);
|
||||
$parameters = [$paramName => $value];
|
||||
|
||||
return $filterQuery->createCondition($expression, $parameters);
|
||||
},
|
||||
'label' => 'entry.filters.http_status_label',
|
||||
'html5' => true,
|
||||
'attr' => [
|
||||
'min' => 100,
|
||||
'max' => 527,
|
||||
],
|
||||
])
|
||||
->add('isArchived', CheckboxFilterType::class, [
|
||||
'label' => 'entry.filters.archived_label',
|
||||
'data' => $options['filter_archived'],
|
||||
])
|
||||
->add('isStarred', CheckboxFilterType::class, [
|
||||
'label' => 'entry.filters.starred_label',
|
||||
'data' => $options['filter_starred'],
|
||||
])
|
||||
->add('isUnread', CheckboxFilterType::class, [
|
||||
'label' => 'entry.filters.unread_label',
|
||||
'data' => $options['filter_unread'],
|
||||
'apply_filter' => function (QueryInterface $filterQuery, $field, $values) {
|
||||
if (false === $values['value']) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$expression = $filterQuery->getExpr()->eq('e.isArchived', 'false');
|
||||
|
||||
return $filterQuery->createCondition($expression);
|
||||
},
|
||||
])
|
||||
->add('isAnnotated', CheckboxFilterType::class, [
|
||||
'label' => 'entry.filters.annotated_label',
|
||||
'data' => $options['filter_annotated'],
|
||||
'apply_filter' => function (QueryInterface $filterQuery, $field, $values) {
|
||||
if (false === $values['value']) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$qb = $filterQuery->getQueryBuilder();
|
||||
$qb->innerJoin('e.annotations', 'a');
|
||||
},
|
||||
])
|
||||
->add('isNotParsed', CheckboxFilterType::class, [
|
||||
'label' => 'entry.filters.parsed_label',
|
||||
'data' => $options['filter_parsed'],
|
||||
])
|
||||
->add('previewPicture', CheckboxFilterType::class, [
|
||||
'apply_filter' => function (QueryInterface $filterQuery, $field, $values) {
|
||||
if (false === $values['value']) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$expression = $filterQuery->getExpr()->isNotNull($field);
|
||||
|
||||
return $filterQuery->createCondition($expression);
|
||||
},
|
||||
'label' => 'entry.filters.preview_picture_label',
|
||||
])
|
||||
->add('isPublic', CheckboxFilterType::class, [
|
||||
'apply_filter' => function (QueryInterface $filterQuery, $field, $values) {
|
||||
if (false === $values['value']) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// is_public isn't a real field
|
||||
// we should use the "uid" field to determine if the entry has been made public
|
||||
$expression = $filterQuery->getExpr()->isNotNull($values['alias'] . '.uid');
|
||||
|
||||
return $filterQuery->createCondition($expression);
|
||||
},
|
||||
'label' => 'entry.filters.is_public_label',
|
||||
])
|
||||
->add('language', ChoiceFilterType::class, [
|
||||
'choices' => array_flip($this->repository->findDistinctLanguageByUser($user->getId())),
|
||||
'label' => 'entry.filters.language_label',
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function getBlockPrefix()
|
||||
{
|
||||
return 'entry_filter';
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'csrf_protection' => false,
|
||||
'validation_groups' => ['filtering'],
|
||||
'filter_archived' => false,
|
||||
'filter_starred' => false,
|
||||
'filter_unread' => false,
|
||||
'filter_annotated' => false,
|
||||
'filter_parsed' => false,
|
||||
]);
|
||||
}
|
||||
}
|
37
src/Form/Type/FeedType.php
Normal file
37
src/Form/Type/FeedType.php
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\CoreBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Wallabag\CoreBundle\Entity\Config;
|
||||
|
||||
class FeedType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('feed_limit', null, [
|
||||
'label' => 'config.form_feed.feed_limit',
|
||||
'property_path' => 'feedLimit',
|
||||
])
|
||||
->add('save', SubmitType::class, [
|
||||
'label' => 'config.form.save',
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Config::class,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getBlockPrefix()
|
||||
{
|
||||
return 'feed_config';
|
||||
}
|
||||
}
|
38
src/Form/Type/IgnoreOriginInstanceRuleType.php
Normal file
38
src/Form/Type/IgnoreOriginInstanceRuleType.php
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\CoreBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Wallabag\CoreBundle\Entity\IgnoreOriginInstanceRule;
|
||||
|
||||
class IgnoreOriginInstanceRuleType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('rule', TextType::class, [
|
||||
'required' => true,
|
||||
'label' => 'config.form_rules.rule_label',
|
||||
])
|
||||
->add('save', SubmitType::class, [
|
||||
'label' => 'config.form.save',
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => IgnoreOriginInstanceRule::class,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getBlockPrefix()
|
||||
{
|
||||
return 'ignore_origin_instance_rule';
|
||||
}
|
||||
}
|
38
src/Form/Type/IgnoreOriginUserRuleType.php
Normal file
38
src/Form/Type/IgnoreOriginUserRuleType.php
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\CoreBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Wallabag\CoreBundle\Entity\IgnoreOriginUserRule;
|
||||
|
||||
class IgnoreOriginUserRuleType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('rule', TextType::class, [
|
||||
'required' => true,
|
||||
'label' => 'config.form_rules.rule_label',
|
||||
])
|
||||
->add('save', SubmitType::class, [
|
||||
'label' => 'config.form.save',
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => IgnoreOriginUserRule::class,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getBlockPrefix()
|
||||
{
|
||||
return 'ignore_origin_user_rule';
|
||||
}
|
||||
}
|
36
src/Form/Type/NewAnnotationType.php
Normal file
36
src/Form/Type/NewAnnotationType.php
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\CoreBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Wallabag\CoreBundle\Entity\Annotation;
|
||||
|
||||
class NewAnnotationType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('text', null, [
|
||||
'empty_data' => '',
|
||||
])
|
||||
->add('quote', null, [
|
||||
'empty_data' => '',
|
||||
'trim' => false,
|
||||
])
|
||||
->add('ranges', CollectionType::class, [
|
||||
'entry_type' => RangeType::class,
|
||||
'allow_add' => true,
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Annotation::class,
|
||||
]);
|
||||
}
|
||||
}
|
35
src/Form/Type/NewEntryType.php
Normal file
35
src/Form/Type/NewEntryType.php
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\CoreBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\UrlType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Wallabag\CoreBundle\Entity\Entry;
|
||||
|
||||
class NewEntryType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('url', UrlType::class, [
|
||||
'required' => true,
|
||||
'label' => 'entry.new.form_new.url_label',
|
||||
'default_protocol' => null,
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Entry::class,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getBlockPrefix()
|
||||
{
|
||||
return 'entry';
|
||||
}
|
||||
}
|
44
src/Form/Type/NewTagType.php
Normal file
44
src/Form/Type/NewTagType.php
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\CoreBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Wallabag\CoreBundle\Entity\Tag;
|
||||
|
||||
class NewTagType extends AbstractType
|
||||
{
|
||||
public const MAX_LENGTH = 40;
|
||||
public const MAX_TAGS = 5;
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('label', TextType::class, [
|
||||
'required' => true,
|
||||
'attr' => [
|
||||
'placeholder' => 'tag.new.placeholder',
|
||||
'max_length' => self::MAX_LENGTH,
|
||||
],
|
||||
])
|
||||
->add('add', SubmitType::class, [
|
||||
'label' => 'tag.new.add',
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Tag::class,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getBlockPrefix()
|
||||
{
|
||||
return 'tag';
|
||||
}
|
||||
}
|
60
src/Form/Type/NewUserType.php
Normal file
60
src/Form/Type/NewUserType.php
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\CoreBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Validator\Constraints\Length;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Wallabag\CoreBundle\Entity\User;
|
||||
|
||||
class NewUserType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('username', TextType::class, [
|
||||
'required' => true,
|
||||
'label' => 'user.form.username_label',
|
||||
])
|
||||
->add('plainPassword', RepeatedType::class, [
|
||||
'type' => PasswordType::class,
|
||||
'invalid_message' => 'validator.password_must_match',
|
||||
'first_options' => ['label' => 'user.form.password_label'],
|
||||
'second_options' => ['label' => 'user.form.repeat_new_password_label'],
|
||||
'constraints' => [
|
||||
new Length([
|
||||
'min' => 8,
|
||||
'minMessage' => 'validator.password_too_short',
|
||||
]),
|
||||
new NotBlank(),
|
||||
],
|
||||
'label' => 'user.form.plain_password_label',
|
||||
])
|
||||
->add('email', EmailType::class, [
|
||||
'label' => 'user.form.email_label',
|
||||
])
|
||||
->add('save', SubmitType::class, [
|
||||
'label' => 'user.form.save',
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => User::class,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getBlockPrefix()
|
||||
{
|
||||
return 'new_user';
|
||||
}
|
||||
}
|
19
src/Form/Type/RangeType.php
Normal file
19
src/Form/Type/RangeType.php
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\CoreBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
class RangeType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('start')
|
||||
->add('startOffset')
|
||||
->add('end')
|
||||
->add('endOffset')
|
||||
;
|
||||
}
|
||||
}
|
36
src/Form/Type/RenameTagType.php
Normal file
36
src/Form/Type/RenameTagType.php
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\CoreBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Wallabag\CoreBundle\Entity\Tag;
|
||||
|
||||
class RenameTagType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('label', TextType::class, [
|
||||
'required' => true,
|
||||
'attr' => [
|
||||
'placeholder' => 'tag.rename.placeholder',
|
||||
],
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Tag::class,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getBlockPrefix()
|
||||
{
|
||||
return 'tag';
|
||||
}
|
||||
}
|
29
src/Form/Type/SearchEntryType.php
Normal file
29
src/Form/Type/SearchEntryType.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\CoreBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class SearchEntryType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->setMethod('GET')
|
||||
->add('term', TextType::class, [
|
||||
'required' => true,
|
||||
'label' => 'entry.new.form_search.term_label',
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'csrf_protection' => false,
|
||||
]);
|
||||
}
|
||||
}
|
29
src/Form/Type/SearchUserType.php
Normal file
29
src/Form/Type/SearchUserType.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\CoreBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class SearchUserType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->setMethod('GET')
|
||||
->add('term', TextType::class, [
|
||||
'required' => true,
|
||||
'label' => 'user.new.form_search.term_label',
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'csrf_protection' => false,
|
||||
]);
|
||||
}
|
||||
}
|
45
src/Form/Type/SiteCredentialType.php
Normal file
45
src/Form/Type/SiteCredentialType.php
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\CoreBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Wallabag\CoreBundle\Entity\SiteCredential;
|
||||
|
||||
class SiteCredentialType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('host', TextType::class, [
|
||||
'label' => 'site_credential.form.host_label',
|
||||
])
|
||||
->add('username', TextType::class, [
|
||||
'label' => 'site_credential.form.username_label',
|
||||
'data' => '',
|
||||
])
|
||||
->add('password', PasswordType::class, [
|
||||
'label' => 'site_credential.form.password_label',
|
||||
])
|
||||
->add('save', SubmitType::class, [
|
||||
'label' => 'config.form.save',
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => SiteCredential::class,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getBlockPrefix()
|
||||
{
|
||||
return 'site_credential';
|
||||
}
|
||||
}
|
29
src/Form/Type/TaggingRuleImportType.php
Normal file
29
src/Form/Type/TaggingRuleImportType.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\CoreBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\FileType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
class TaggingRuleImportType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('file', FileType::class, [
|
||||
'label' => 'config.form_rules.file_label',
|
||||
'required' => true,
|
||||
])
|
||||
->add('import', SubmitType::class, [
|
||||
'label' => 'config.form_rules.import_submit',
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function getBlockPrefix()
|
||||
{
|
||||
return 'upload_tagging_rule_file';
|
||||
}
|
||||
}
|
47
src/Form/Type/TaggingRuleType.php
Normal file
47
src/Form/Type/TaggingRuleType.php
Normal file
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\CoreBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Wallabag\CoreBundle\Entity\TaggingRule;
|
||||
use Wallabag\CoreBundle\Form\DataTransformer\StringToListTransformer;
|
||||
|
||||
class TaggingRuleType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('rule', TextType::class, [
|
||||
'required' => true,
|
||||
'label' => 'config.form_rules.rule_label',
|
||||
])
|
||||
->add('save', SubmitType::class, [
|
||||
'label' => 'config.form.save',
|
||||
])
|
||||
;
|
||||
|
||||
$tagsField = $builder
|
||||
->create('tags', TextType::class, [
|
||||
'label' => 'config.form_rules.tags_label',
|
||||
])
|
||||
->addModelTransformer(new StringToListTransformer(','));
|
||||
|
||||
$builder->add($tagsField);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => TaggingRule::class,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getBlockPrefix()
|
||||
{
|
||||
return 'tagging_rule';
|
||||
}
|
||||
}
|
34
src/Form/Type/UploadImportType.php
Normal file
34
src/Form/Type/UploadImportType.php
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\CoreBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\FileType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
class UploadImportType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('file', FileType::class, [
|
||||
'label' => 'import.form.file_label',
|
||||
'required' => true,
|
||||
])
|
||||
->add('mark_as_read', CheckboxType::class, [
|
||||
'label' => 'import.form.mark_as_read_label',
|
||||
'required' => false,
|
||||
])
|
||||
->add('save', SubmitType::class, [
|
||||
'label' => 'import.form.save_label',
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function getBlockPrefix()
|
||||
{
|
||||
return 'upload_import_file';
|
||||
}
|
||||
}
|
49
src/Form/Type/UserInformationType.php
Normal file
49
src/Form/Type/UserInformationType.php
Normal file
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\CoreBundle\Form\Type;
|
||||
|
||||
use FOS\UserBundle\Form\Type\RegistrationFormType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Wallabag\CoreBundle\Entity\User;
|
||||
|
||||
class UserInformationType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('name', TextType::class, [
|
||||
'label' => 'config.form_user.name_label',
|
||||
])
|
||||
->add('email', EmailType::class, [
|
||||
'label' => 'config.form_user.email_label',
|
||||
])
|
||||
->add('save', SubmitType::class, [
|
||||
'label' => 'config.form.save',
|
||||
])
|
||||
->remove('username')
|
||||
->remove('plainPassword')
|
||||
;
|
||||
}
|
||||
|
||||
public function getParent()
|
||||
{
|
||||
return RegistrationFormType::class;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => User::class,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getBlockPrefix()
|
||||
{
|
||||
return 'update_user';
|
||||
}
|
||||
}
|
56
src/Form/Type/UserType.php
Normal file
56
src/Form/Type/UserType.php
Normal file
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\CoreBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Wallabag\CoreBundle\Entity\User;
|
||||
|
||||
class UserType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('name', TextType::class, [
|
||||
'required' => false,
|
||||
'label' => 'user.form.name_label',
|
||||
])
|
||||
->add('username', TextType::class, [
|
||||
'required' => true,
|
||||
'label' => 'user.form.username_label',
|
||||
])
|
||||
->add('email', EmailType::class, [
|
||||
'required' => true,
|
||||
'label' => 'user.form.email_label',
|
||||
])
|
||||
->add('enabled', CheckboxType::class, [
|
||||
'required' => false,
|
||||
'label' => 'user.form.enabled_label',
|
||||
])
|
||||
->add('emailTwoFactor', CheckboxType::class, [
|
||||
'required' => false,
|
||||
'label' => 'user.form.twofactor_email_label',
|
||||
])
|
||||
->add('googleTwoFactor', CheckboxType::class, [
|
||||
'required' => false,
|
||||
'label' => 'user.form.twofactor_google_label',
|
||||
'mapped' => false,
|
||||
])
|
||||
->add('save', SubmitType::class, [
|
||||
'label' => 'user.form.save',
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => User::class,
|
||||
]);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue