diff --git a/app/config/config.yml b/app/config/config.yml index 7dc3698e2..50ba978c8 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -112,14 +112,8 @@ fos_rest: pdf: true epub: true mobi: true - templating_formats: - html: false - force_redirects: - html: true failed_validation: HTTP_BAD_REQUEST - default_engine: twig - routing_loader: - default_format: json + routing_loader: false format_listener: enabled: true rules: diff --git a/app/config/routing.yml b/app/config/routing.yml index fdf6a0d30..81fd63067 100644 --- a/app/config/routing.yml +++ b/app/config/routing.yml @@ -1,6 +1,7 @@ wallabag_annotation: - type : rest - resource: "@WallabagAnnotationBundle/Resources/config/routing_annotations.yml" + resource: "@WallabagAnnotationBundle/Controller/" + type: annotation + prefix: / wallabag_import: resource: "@WallabagImportBundle/Controller/" @@ -25,11 +26,6 @@ doc-api: resource: "@NelmioApiDocBundle/Resources/config/routing/swaggerui.xml" prefix: /api/doc -rest : - type : rest - resource : "routing_rest.yml" - prefix : /api - homepage: path: "/{page}" defaults: diff --git a/app/config/routing_rest.yml b/app/config/routing_rest.yml deleted file mode 100644 index 29f4ab14c..000000000 --- a/app/config/routing_rest.yml +++ /dev/null @@ -1,3 +0,0 @@ -Rest_Wallabag: - type : rest - resource: "@WallabagApiBundle/Resources/config/routing_rest.yml" diff --git a/app/config/services.yml b/app/config/services.yml index a479b006a..637e7f6d0 100644 --- a/app/config/services.yml +++ b/app/config/services.yml @@ -159,6 +159,9 @@ services: calls: - ["addSubscriber", ["@bd_guzzle_site_authenticator.authenticator_subscriber"]] + RulerZ\RulerZ: + alias: rulerz + Wallabag\CoreBundle\Operator\PHP\Matches: tags: - { name: rulerz.operator, target: native, operator: matches } diff --git a/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php b/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php index 4bf51b5f2..0f2cc1e09 100644 --- a/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php +++ b/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php @@ -8,6 +8,7 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Routing\Annotation\Route; use Wallabag\AnnotationBundle\Entity\Annotation; use Wallabag\AnnotationBundle\Form\EditAnnotationType; use Wallabag\AnnotationBundle\Form\NewAnnotationType; @@ -20,6 +21,8 @@ class WallabagAnnotationController extends AbstractFOSRestController * * @see Wallabag\ApiBundle\Controller\WallabagRestController * + * @Route("/annotations/{entry}.{_format}", methods={"GET"}, name="annotations_get_annotations", defaults={"_format": "json"}) + * * @return JsonResponse */ public function getAnnotationsAction(Entry $entry) @@ -39,9 +42,11 @@ class WallabagAnnotationController extends AbstractFOSRestController /** * Creates a new annotation. * - * @return JsonResponse - * * @see Wallabag\ApiBundle\Controller\WallabagRestController + * + * @Route("/annotations/{entry}.{_format}", methods={"POST"}, name="annotations_post_annotation", defaults={"_format": "json"}) + * + * @return JsonResponse */ public function postAnnotationAction(Request $request, Entry $entry) { @@ -74,6 +79,7 @@ class WallabagAnnotationController extends AbstractFOSRestController * * @see Wallabag\ApiBundle\Controller\WallabagRestController * + * @Route("/annotations/{annotation}.{_format}", methods={"PUT"}, name="annotations_put_annotation", defaults={"_format": "json"}) * @ParamConverter("annotation", class="Wallabag\AnnotationBundle\Entity\Annotation") * * @return JsonResponse @@ -106,6 +112,7 @@ class WallabagAnnotationController extends AbstractFOSRestController * * @see Wallabag\ApiBundle\Controller\WallabagRestController * + * @Route("/annotations/{annotation}.{_format}", methods={"DELETE"}, name="annotations_delete_annotation", defaults={"_format": "json"}) * @ParamConverter("annotation", class="Wallabag\AnnotationBundle\Entity\Annotation") * * @return JsonResponse diff --git a/src/Wallabag/AnnotationBundle/Resources/config/routing_annotations.yml b/src/Wallabag/AnnotationBundle/Resources/config/routing_annotations.yml deleted file mode 100644 index ba076b9f4..000000000 --- a/src/Wallabag/AnnotationBundle/Resources/config/routing_annotations.yml +++ /dev/null @@ -1,4 +0,0 @@ -annotations: - type: rest - resource: 'Wallabag\AnnotationBundle\Controller\WallabagAnnotationController' - name_prefix: annotations_ diff --git a/src/Wallabag/ApiBundle/Controller/AnnotationRestController.php b/src/Wallabag/ApiBundle/Controller/AnnotationRestController.php index 61604e7ef..7eb7a787a 100644 --- a/src/Wallabag/ApiBundle/Controller/AnnotationRestController.php +++ b/src/Wallabag/ApiBundle/Controller/AnnotationRestController.php @@ -7,6 +7,7 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; use Swagger\Annotations as SWG; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Routing\Annotation\Route; use Wallabag\AnnotationBundle\Entity\Annotation; use Wallabag\CoreBundle\Entity\Entry; @@ -32,6 +33,8 @@ class AnnotationRestController extends WallabagRestController * ) * ) * + * @Route("/api/annotations/{entry}.{_format}", methods={"GET"}, name="api_get_annotations", defaults={"_format": "json"}) + * * @return JsonResponse */ public function getAnnotationsAction(Entry $entry) @@ -88,6 +91,8 @@ class AnnotationRestController extends WallabagRestController * ) * ) * + * @Route("/api/annotations/{entry}.{_format}", methods={"POST"}, name="api_post_annotation", defaults={"_format": "json"}) + * * @return JsonResponse */ public function postAnnotationAction(Request $request, Entry $entry) @@ -120,6 +125,7 @@ class AnnotationRestController extends WallabagRestController * ) * ) * + * @Route("/api/annotations/{annotation}.{_format}", methods={"PUT"}, name="api_put_annotation", defaults={"_format": "json"}) * @ParamConverter("annotation", class="Wallabag\AnnotationBundle\Entity\Annotation") * * @return JsonResponse @@ -154,6 +160,7 @@ class AnnotationRestController extends WallabagRestController * ) * ) * + * @Route("/api/annotations/{annotation}.{_format}", methods={"DELETE"}, name="api_delete_annotation", defaults={"_format": "json"}) * @ParamConverter("annotation", class="Wallabag\AnnotationBundle\Entity\Annotation") * * @return JsonResponse diff --git a/src/Wallabag/ApiBundle/Controller/ConfigRestController.php b/src/Wallabag/ApiBundle/Controller/ConfigRestController.php index ac694e48e..0bcc20e01 100644 --- a/src/Wallabag/ApiBundle/Controller/ConfigRestController.php +++ b/src/Wallabag/ApiBundle/Controller/ConfigRestController.php @@ -7,6 +7,7 @@ use JMS\Serializer\SerializerInterface; use Nelmio\ApiDocBundle\Annotation\Operation; use Swagger\Annotations as SWG; use Symfony\Component\HttpFoundation\JsonResponse; +use Symfony\Component\Routing\Annotation\Route; class ConfigRestController extends WallabagRestController { @@ -22,6 +23,8 @@ class ConfigRestController extends WallabagRestController * ) * ) * + * @Route("/api/config.{_format}", methods={"GET"}, name="api_get_config", defaults={"_format": "json"}) + * * @return JsonResponse */ public function getConfigAction() diff --git a/src/Wallabag/ApiBundle/Controller/EntryRestController.php b/src/Wallabag/ApiBundle/Controller/EntryRestController.php index 47353b301..98f11b52a 100644 --- a/src/Wallabag/ApiBundle/Controller/EntryRestController.php +++ b/src/Wallabag/ApiBundle/Controller/EntryRestController.php @@ -2,7 +2,7 @@ namespace Wallabag\ApiBundle\Controller; -use Hateoas\Configuration\Route; +use Hateoas\Configuration\Route as HateoasRoute; use Hateoas\Representation\Factory\PagerfantaFactory; use Nelmio\ApiDocBundle\Annotation\Operation; use Pagerfanta\Pagerfanta; @@ -13,6 +13,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\HttpException; +use Symfony\Component\Routing\Annotation\Route; use Wallabag\CoreBundle\Entity\Entry; use Wallabag\CoreBundle\Entity\Tag; use Wallabag\CoreBundle\Event\EntryDeletedEvent; @@ -80,6 +81,8 @@ class EntryRestController extends WallabagRestController * ) * ) * + * @Route("/api/entries/exists.{_format}", methods={"GET"}, name="api_get_entries_exists", defaults={"_format": "json"}) + * * @return JsonResponse */ public function getEntriesExistsAction(Request $request) @@ -272,6 +275,8 @@ class EntryRestController extends WallabagRestController * ) * ) * + * @Route("/api/entries.{_format}", methods={"GET"}, name="api_get_entries", defaults={"_format": "json"}) + * * @return JsonResponse */ public function getEntriesAction(Request $request) @@ -314,7 +319,7 @@ class EntryRestController extends WallabagRestController $pagerfantaFactory = new PagerfantaFactory('page', 'perPage'); $paginatedCollection = $pagerfantaFactory->createRepresentation( $pager, - new Route( + new HateoasRoute( 'api_get_entries', [ 'archive' => $isArchived, @@ -355,6 +360,8 @@ class EntryRestController extends WallabagRestController * ) * ) * + * @Route("/api/entries/{entry}.{_format}", methods={"GET"}, name="api_get_entry", defaults={"_format": "json"}) + * * @return JsonResponse */ public function getEntryAction(Entry $entry) @@ -393,6 +400,8 @@ class EntryRestController extends WallabagRestController * ) * ) * + * @Route("/api/entries/{entry}/export.{_format}", methods={"GET"}, name="api_get_entry_export", defaults={"_format": "json"}) + * * @return Response */ public function getEntryExportAction(Entry $entry, Request $request) @@ -426,6 +435,8 @@ class EntryRestController extends WallabagRestController * ) * ) * + * @Route("/api/entries/list.{_format}", methods={"DELETE"}, name="api_delete_entries_list", defaults={"_format": "json"}) + * * @return JsonResponse */ public function deleteEntriesListAction(Request $request) @@ -483,6 +494,8 @@ class EntryRestController extends WallabagRestController * ) * ) * + * @Route("/api/entries/lists.{_format}", methods={"POST"}, name="api_post_entries_list", defaults={"_format": "json"}) + * * @throws HttpException When limit is reached * * @return JsonResponse @@ -666,6 +679,8 @@ class EntryRestController extends WallabagRestController * ) * ) * + * @Route("/api/entries.{_format}", methods={"POST"}, name="api_post_entries", defaults={"_format": "json"}) + * * @return JsonResponse */ public function postEntriesAction(Request $request) @@ -869,6 +884,8 @@ class EntryRestController extends WallabagRestController * ) * ) * + * @Route("/api/entries/{entry}.{_format}", methods={"PATCH"}, name="api_patch_entries", defaults={"_format": "json"}) + * * @return JsonResponse */ public function patchEntriesAction(Entry $entry, Request $request) @@ -985,6 +1002,8 @@ class EntryRestController extends WallabagRestController * ) * ) * + * @Route("/api/entries/{entry}/reload.{_format}", methods={"PATCH"}, name="api_patch_entries_reload", defaults={"_format": "json"}) + * * @return JsonResponse */ public function patchEntriesReloadAction(Entry $entry) @@ -1041,6 +1060,8 @@ class EntryRestController extends WallabagRestController * ) * ) * + * @Route("/api/entries/{entry}.{_format}", methods={"DELETE"}, name="api_delete_entries", defaults={"_format": "json"}) + * * @return JsonResponse */ public function deleteEntriesAction(Entry $entry, Request $request) @@ -1091,6 +1112,8 @@ class EntryRestController extends WallabagRestController * ) * ) * + * @Route("/api/entries/{entry}/tags.{_format}", methods={"GET"}, name="api_get_entries_tags", defaults={"_format": "json"}) + * * @return JsonResponse */ public function getEntriesTagsAction(Entry $entry) @@ -1131,6 +1154,8 @@ class EntryRestController extends WallabagRestController * ) * ) * + * @Route("/api/entries/{entry}/tags.{_format}", methods={"POST"}, name="api_post_entries_tags", defaults={"_format": "json"}) + * * @return JsonResponse */ public function postEntriesTagsAction(Request $request, Entry $entry) @@ -1178,6 +1203,8 @@ class EntryRestController extends WallabagRestController * ) * ) * + * @Route("/api/entries/{entry}/tags/{tag}.{_format}", methods={"DELETE"}, name="api_delete_entries_tags", defaults={"_format": "json"}) + * * @return JsonResponse */ public function deleteEntriesTagsAction(Entry $entry, Tag $tag) @@ -1212,6 +1239,8 @@ class EntryRestController extends WallabagRestController * ) * ) * + * @Route("/api/entries/tags/list.{_format}", methods={"DELETE"}, name="api_delete_entries_tags_list", defaults={"_format": "json"}) + * * @return JsonResponse */ public function deleteEntriesTagsListAction(Request $request) @@ -1280,6 +1309,8 @@ class EntryRestController extends WallabagRestController * ) * ) * + * @Route("/api/entries/tags/lists.{_format}", methods={"POST"}, name="api_post_entries_tags_list", defaults={"_format": "json"}) + * * @return JsonResponse */ public function postEntriesTagsListAction(Request $request) diff --git a/src/Wallabag/ApiBundle/Controller/SearchRestController.php b/src/Wallabag/ApiBundle/Controller/SearchRestController.php index 277896ccf..caaf4772a 100644 --- a/src/Wallabag/ApiBundle/Controller/SearchRestController.php +++ b/src/Wallabag/ApiBundle/Controller/SearchRestController.php @@ -2,7 +2,7 @@ namespace Wallabag\ApiBundle\Controller; -use Hateoas\Configuration\Route; +use Hateoas\Configuration\Route as HateoasRoute; use Hateoas\Representation\Factory\PagerfantaFactory; use Nelmio\ApiDocBundle\Annotation\Operation; use Pagerfanta\Doctrine\ORM\QueryAdapter as DoctrineORMAdapter; @@ -10,6 +10,7 @@ use Pagerfanta\Pagerfanta; use Swagger\Annotations as SWG; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Routing\Annotation\Route; use Wallabag\CoreBundle\Repository\EntryRepository; class SearchRestController extends WallabagRestController @@ -53,6 +54,8 @@ class SearchRestController extends WallabagRestController * ) * ) * + * @Route("/api/search.{_format}", methods={"GET"}, name="api_get_search", defaults={"_format": "json"}) + * * @return JsonResponse */ public function getSearchAction(Request $request) @@ -79,7 +82,7 @@ class SearchRestController extends WallabagRestController $pagerfantaFactory = new PagerfantaFactory('page', 'perPage'); $paginatedCollection = $pagerfantaFactory->createRepresentation( $pager, - new Route( + new HateoasRoute( 'api_get_search', [ 'term' => $term, diff --git a/src/Wallabag/ApiBundle/Controller/TagRestController.php b/src/Wallabag/ApiBundle/Controller/TagRestController.php index f51557567..3cc623909 100644 --- a/src/Wallabag/ApiBundle/Controller/TagRestController.php +++ b/src/Wallabag/ApiBundle/Controller/TagRestController.php @@ -7,6 +7,7 @@ use Nelmio\ApiDocBundle\Annotation\Operation; use Swagger\Annotations as SWG; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Routing\Annotation\Route; use Wallabag\CoreBundle\Entity\Entry; use Wallabag\CoreBundle\Entity\Tag; @@ -24,6 +25,8 @@ class TagRestController extends WallabagRestController * ) * ) * + * @Route("/api/tags.{_format}", methods={"GET"}, name="api_get_tags", defaults={"_format": "json"}) + * * @return JsonResponse */ public function getTagsAction() @@ -59,6 +62,8 @@ class TagRestController extends WallabagRestController * ) * ) * + * @Route("/api/tag/label.{_format}", methods={"DELETE"}, name="api_delete_tag_label", defaults={"_format": "json"}) + * * @return JsonResponse */ public function deleteTagLabelAction(Request $request) @@ -107,6 +112,8 @@ class TagRestController extends WallabagRestController * ) * ) * + * @Route("/api/tags/label.{_format}", methods={"DELETE"}, name="api_delete_tags_label", defaults={"_format": "json"}) + * * @return JsonResponse */ public function deleteTagsLabelAction(Request $request) @@ -152,6 +159,8 @@ class TagRestController extends WallabagRestController * ) * ) * + * @Route("/api/tags/{tag}.{_format}", methods={"DELETE"}, name="api_delete_tag", defaults={"_format": "json"}) + * * @return JsonResponse */ public function deleteTagAction(Tag $tag) diff --git a/src/Wallabag/ApiBundle/Controller/TaggingRuleRestController.php b/src/Wallabag/ApiBundle/Controller/TaggingRuleRestController.php index e6c3e5544..d7bf347d1 100644 --- a/src/Wallabag/ApiBundle/Controller/TaggingRuleRestController.php +++ b/src/Wallabag/ApiBundle/Controller/TaggingRuleRestController.php @@ -7,6 +7,7 @@ use JMS\Serializer\SerializerBuilder; use Nelmio\ApiDocBundle\Annotation\Operation; use Swagger\Annotations as SWG; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\Routing\Annotation\Route; class TaggingRuleRestController extends WallabagRestController { @@ -22,6 +23,8 @@ class TaggingRuleRestController extends WallabagRestController * ) * ) * + * @Route("/api/taggingrule/export.{_format}", methods={"GET"}, name="api_get_taggingrule_export", defaults={"_format": "json"}) + * * @return Response */ public function getTaggingruleExportAction() diff --git a/src/Wallabag/ApiBundle/Controller/UserRestController.php b/src/Wallabag/ApiBundle/Controller/UserRestController.php index 9988f2890..348536d32 100644 --- a/src/Wallabag/ApiBundle/Controller/UserRestController.php +++ b/src/Wallabag/ApiBundle/Controller/UserRestController.php @@ -13,6 +13,7 @@ use Swagger\Annotations as SWG; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Translation\TranslatorInterface; use Wallabag\ApiBundle\Entity\Client; use Wallabag\UserBundle\Entity\User; @@ -32,6 +33,8 @@ class UserRestController extends WallabagRestController * ) * ) * + * @Route("/api/user.{_format}", methods={"GET"}, name="api_get_user", defaults={"_format": "json"}) + * * @return JsonResponse */ public function getUserAction() @@ -83,6 +86,8 @@ class UserRestController extends WallabagRestController * * @todo Make this method (or the whole API) accessible only through https * + * @Route("/api/user.{_format}", methods={"PUT"}, name="api_put_user", defaults={"_format": "json"}) + * * @return JsonResponse */ public function putUserAction(Request $request) diff --git a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php index b2349d38d..fedc3910c 100644 --- a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php +++ b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php @@ -8,6 +8,7 @@ use JMS\Serializer\SerializerInterface; use Nelmio\ApiDocBundle\Annotation\Operation; use Swagger\Annotations as SWG; use Symfony\Component\HttpFoundation\JsonResponse; +use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Component\Security\Core\Exception\AccessDeniedException; @@ -28,6 +29,8 @@ class WallabagRestController extends AbstractFOSRestController * * @deprecated Should use info endpoint instead * + * @Route("/api/version.{_format}", methods={"GET"}, name="api_get_version", defaults={"_format": "json"}) + * * @return JsonResponse */ public function getVersionAction() @@ -50,6 +53,8 @@ class WallabagRestController extends AbstractFOSRestController * ) * ) * + * @Route("/api/info.{_format}", methods={"GET"}, name="api_get_info", defaults={"_format": "json"}) + * * @return JsonResponse */ public function getInfoAction()