diff options
Diffstat (limited to 'src/Wallabag')
8 files changed, 31 insertions, 19 deletions
diff --git a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php index f8a2745a..d9035cac 100644 --- a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php +++ b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php | |||
@@ -8,6 +8,7 @@ use Hateoas\Representation\Factory\PagerfantaFactory; | |||
8 | use Nelmio\ApiDocBundle\Annotation\ApiDoc; | 8 | use Nelmio\ApiDocBundle\Annotation\ApiDoc; |
9 | use Symfony\Component\HttpFoundation\Request; | 9 | use Symfony\Component\HttpFoundation\Request; |
10 | use Symfony\Component\HttpFoundation\Response; | 10 | use Symfony\Component\HttpFoundation\Response; |
11 | use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | ||
11 | use Wallabag\CoreBundle\Entity\Entry; | 12 | use Wallabag\CoreBundle\Entity\Entry; |
12 | use Wallabag\CoreBundle\Entity\Tag; | 13 | use Wallabag\CoreBundle\Entity\Tag; |
13 | 14 | ||
@@ -84,7 +85,7 @@ class WallabagRestController extends FOSRestController | |||
84 | $pagerfantaFactory = new PagerfantaFactory('page', 'perPage'); | 85 | $pagerfantaFactory = new PagerfantaFactory('page', 'perPage'); |
85 | $paginatedCollection = $pagerfantaFactory->createRepresentation( | 86 | $paginatedCollection = $pagerfantaFactory->createRepresentation( |
86 | $pager, | 87 | $pager, |
87 | new Route('api_get_entries', [], $absolute = true) | 88 | new Route('api_get_entries', [], UrlGeneratorInterface::ABSOLUTE_URL) |
88 | ); | 89 | ); |
89 | 90 | ||
90 | $json = $this->get('serializer')->serialize($paginatedCollection, 'json'); | 91 | $json = $this->get('serializer')->serialize($paginatedCollection, 'json'); |
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php index 83e5b57d..dda0a456 100644 --- a/src/Wallabag/CoreBundle/Controller/EntryController.php +++ b/src/Wallabag/CoreBundle/Controller/EntryController.php | |||
@@ -234,7 +234,7 @@ class EntryController extends Controller | |||
234 | throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type)); | 234 | throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type)); |
235 | } | 235 | } |
236 | 236 | ||
237 | $form = $this->createForm(new EntryFilterType($repository, $this->getUser())); | 237 | $form = $this->createForm(EntryFilterType::class); |
238 | 238 | ||
239 | if ($request->query->has($form->getName())) { | 239 | if ($request->query->has($form->getName())) { |
240 | // manually bind values from the request | 240 | // manually bind values from the request |
diff --git a/src/Wallabag/CoreBundle/Filter/EntryFilterType.php b/src/Wallabag/CoreBundle/Filter/EntryFilterType.php index 4430c971..c38be832 100644 --- a/src/Wallabag/CoreBundle/Filter/EntryFilterType.php +++ b/src/Wallabag/CoreBundle/Filter/EntryFilterType.php | |||
@@ -12,7 +12,7 @@ use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\ChoiceFilterType; | |||
12 | use Symfony\Component\Form\AbstractType; | 12 | use Symfony\Component\Form\AbstractType; |
13 | use Symfony\Component\Form\FormBuilderInterface; | 13 | use Symfony\Component\Form\FormBuilderInterface; |
14 | use Symfony\Component\OptionsResolver\OptionsResolver; | 14 | use Symfony\Component\OptionsResolver\OptionsResolver; |
15 | use Wallabag\UserBundle\Entity\User; | 15 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; |
16 | 16 | ||
17 | class EntryFilterType extends AbstractType | 17 | class EntryFilterType extends AbstractType |
18 | { | 18 | { |
@@ -23,12 +23,12 @@ class EntryFilterType extends AbstractType | |||
23 | * Repository & user are used to get a list of language entries for this user. | 23 | * Repository & user are used to get a list of language entries for this user. |
24 | * | 24 | * |
25 | * @param EntityRepository $entryRepository | 25 | * @param EntityRepository $entryRepository |
26 | * @param User $user | 26 | * @param TokenStorage $token |
27 | */ | 27 | */ |
28 | public function __construct(EntityRepository $entryRepository, User $user) | 28 | public function __construct(EntityRepository $entryRepository, TokenStorage $token) |
29 | { | 29 | { |
30 | $this->repository = $entryRepository; | 30 | $this->repository = $entryRepository; |
31 | $this->user = $user; | 31 | $this->user = $token->getToken()->getUser(); |
32 | } | 32 | } |
33 | 33 | ||
34 | public function buildForm(FormBuilderInterface $builder, array $options) | 34 | public function buildForm(FormBuilderInterface $builder, array $options) |
@@ -54,13 +54,13 @@ class EntryFilterType extends AbstractType | |||
54 | ) | 54 | ) |
55 | ->add('domainName', TextFilterType::class, array( | 55 | ->add('domainName', TextFilterType::class, array( |
56 | 'apply_filter' => function (QueryInterface $filterQuery, $field, $values) { | 56 | 'apply_filter' => function (QueryInterface $filterQuery, $field, $values) { |
57 | $value = $values['value']; | 57 | $value = $values['value']; |
58 | if (strlen($value) <= 2 || empty($value)) { | 58 | if (strlen($value) <= 2 || empty($value)) { |
59 | return; | 59 | return; |
60 | } | 60 | } |
61 | $expression = $filterQuery->getExpr()->like($field, $filterQuery->getExpr()->literal('%'.$value.'%')); | 61 | $expression = $filterQuery->getExpr()->like($field, $filterQuery->getExpr()->literal('%'.$value.'%')); |
62 | 62 | ||
63 | return $filterQuery->createCondition($expression); | 63 | return $filterQuery->createCondition($expression); |
64 | }, | 64 | }, |
65 | )) | 65 | )) |
66 | ->add('isArchived', CheckboxFilterType::class) | 66 | ->add('isArchived', CheckboxFilterType::class) |
diff --git a/src/Wallabag/CoreBundle/Form/Type/UserInformationType.php b/src/Wallabag/CoreBundle/Form/Type/UserInformationType.php index f52e409a..f491b0ae 100644 --- a/src/Wallabag/CoreBundle/Form/Type/UserInformationType.php +++ b/src/Wallabag/CoreBundle/Form/Type/UserInformationType.php | |||
@@ -26,7 +26,7 @@ class UserInformationType extends AbstractType | |||
26 | 26 | ||
27 | public function getParent() | 27 | public function getParent() |
28 | { | 28 | { |
29 | return 'fos_user_registration'; | 29 | return 'FOS\UserBundle\Form\Type\RegistrationFormType'; |
30 | } | 30 | } |
31 | 31 | ||
32 | public function configureOptions(OptionsResolver $resolver) | 32 | public function configureOptions(OptionsResolver $resolver) |
diff --git a/src/Wallabag/CoreBundle/Resources/config/services.yml b/src/Wallabag/CoreBundle/Resources/config/services.yml index e8dafc5d..43600735 100644 --- a/src/Wallabag/CoreBundle/Resources/config/services.yml +++ b/src/Wallabag/CoreBundle/Resources/config/services.yml | |||
@@ -14,6 +14,14 @@ services: | |||
14 | tags: | 14 | tags: |
15 | - { name: form.type } | 15 | - { name: form.type } |
16 | 16 | ||
17 | wallabag_core.filter.type.entry: | ||
18 | class: Wallabag\CoreBundle\Filter\EntryFilterType | ||
19 | arguments: | ||
20 | - "@wallabag_core.entry_repository" | ||
21 | - "@security.token_storage" | ||
22 | tags: | ||
23 | - { name: form.type } | ||
24 | |||
17 | wallabag_core.param_converter.username_rsstoken_converter: | 25 | wallabag_core.param_converter.username_rsstoken_converter: |
18 | class: Wallabag\CoreBundle\ParamConverter\UsernameRssTokenConverter | 26 | class: Wallabag\CoreBundle\ParamConverter\UsernameRssTokenConverter |
19 | tags: | 27 | tags: |
diff --git a/src/Wallabag/ImportBundle/Controller/PocketController.php b/src/Wallabag/ImportBundle/Controller/PocketController.php index a0853383..72dc2696 100644 --- a/src/Wallabag/ImportBundle/Controller/PocketController.php +++ b/src/Wallabag/ImportBundle/Controller/PocketController.php | |||
@@ -3,6 +3,7 @@ | |||
3 | namespace Wallabag\ImportBundle\Controller; | 3 | namespace Wallabag\ImportBundle\Controller; |
4 | 4 | ||
5 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | 5 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
6 | use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | ||
6 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | 7 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
7 | 8 | ||
8 | class PocketController extends Controller | 9 | class PocketController extends Controller |
@@ -23,12 +24,12 @@ class PocketController extends Controller | |||
23 | public function authAction() | 24 | public function authAction() |
24 | { | 25 | { |
25 | $requestToken = $this->get('wallabag_import.pocket.import') | 26 | $requestToken = $this->get('wallabag_import.pocket.import') |
26 | ->getRequestToken($this->generateUrl('import', [], true)); | 27 | ->getRequestToken($this->generateUrl('import', UrlGeneratorInterface::ABSOLUTE_URL)); |
27 | 28 | ||
28 | $this->get('session')->set('import.pocket.code', $requestToken); | 29 | $this->get('session')->set('import.pocket.code', $requestToken); |
29 | 30 | ||
30 | return $this->redirect( | 31 | return $this->redirect( |
31 | 'https://getpocket.com/auth/authorize?request_token='.$requestToken.'&redirect_uri='.$this->generateUrl('import_pocket_callback', [], true), | 32 | 'https://getpocket.com/auth/authorize?request_token='.$requestToken.'&redirect_uri='.$this->generateUrl('import_pocket_callback', UrlGeneratorInterface::ABSOLUTE_URL), |
32 | 301 | 33 | 301 |
33 | ); | 34 | ); |
34 | } | 35 | } |
diff --git a/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php b/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php index e50a6c35..35fe620f 100644 --- a/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php +++ b/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php | |||
@@ -14,7 +14,7 @@ class WallabagV1Controller extends Controller | |||
14 | */ | 14 | */ |
15 | public function indexAction(Request $request) | 15 | public function indexAction(Request $request) |
16 | { | 16 | { |
17 | $form = $this->createForm(new UploadImportType()); | 17 | $form = $this->createForm(UploadImportType::class); |
18 | $form->handleRequest($request); | 18 | $form->handleRequest($request); |
19 | 19 | ||
20 | $wallabag = $this->get('wallabag_import.wallabag_v1.import'); | 20 | $wallabag = $this->get('wallabag_import.wallabag_v1.import'); |
diff --git a/src/Wallabag/ImportBundle/Form/Type/UploadImportType.php b/src/Wallabag/ImportBundle/Form/Type/UploadImportType.php index 415890f3..2e6b59cb 100644 --- a/src/Wallabag/ImportBundle/Form/Type/UploadImportType.php +++ b/src/Wallabag/ImportBundle/Form/Type/UploadImportType.php | |||
@@ -4,18 +4,20 @@ namespace Wallabag\ImportBundle\Form\Type; | |||
4 | 4 | ||
5 | use Symfony\Component\Form\AbstractType; | 5 | use Symfony\Component\Form\AbstractType; |
6 | use Symfony\Component\Form\FormBuilderInterface; | 6 | use Symfony\Component\Form\FormBuilderInterface; |
7 | use Symfony\Component\Form\Extension\Core\Type\SubmitType; | ||
8 | use Symfony\Component\Form\Extension\Core\Type\FileType; | ||
7 | 9 | ||
8 | class UploadImportType extends AbstractType | 10 | class UploadImportType extends AbstractType |
9 | { | 11 | { |
10 | public function buildForm(FormBuilderInterface $builder, array $options) | 12 | public function buildForm(FormBuilderInterface $builder, array $options) |
11 | { | 13 | { |
12 | $builder | 14 | $builder |
13 | ->add('file', 'file') | 15 | ->add('file', FileType::class) |
14 | ->add('save', 'submit') | 16 | ->add('save', SubmitType::class) |
15 | ; | 17 | ; |
16 | } | 18 | } |
17 | 19 | ||
18 | public function getName() | 20 | public function getBlockPrefix() |
19 | { | 21 | { |
20 | return 'upload_import_file'; | 22 | return 'upload_import_file'; |
21 | } | 23 | } |