diff --git a/composer.json b/composer.json index 033cb3997e..32bc31c8a2 100755 --- a/composer.json +++ b/composer.json @@ -160,7 +160,8 @@ "tgalopin/html-sanitizer-bundle": "^1.1", "twig/extensions": "^1.5", "vich/uploader-bundle": "^1.13", - "webit/eval-math": "~1.0" + "webit/eval-math": "~1.0", + "api-platform/api-pack": "^1.2" }, "config": { "component-dir": "public/assets" diff --git a/config/bundles.php b/config/bundles.php index 1528609d48..097a13c198 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -72,4 +72,6 @@ return [ Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle::class => ['all' => true], Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true], Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true], + Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true], + ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true], ]; diff --git a/config/packages/api_platform.yaml b/config/packages/api_platform.yaml new file mode 100644 index 0000000000..4c0546f6d7 --- /dev/null +++ b/config/packages/api_platform.yaml @@ -0,0 +1,7 @@ +api_platform: + mapping: + paths: ['%kernel.project_dir%/src/CoreBundle/Entity', '%kernel.project_dir%/src/CourseBundle/Entity'] + patch_formats: + json: ['application/merge-patch+json'] + swagger: + versions: [3] diff --git a/config/packages/framework.yaml b/config/packages/framework.yaml index 9366700411..4bdaefda3e 100644 --- a/config/packages/framework.yaml +++ b/config/packages/framework.yaml @@ -17,3 +17,4 @@ framework: annotations: cache: file file_cache_dir: "%kernel.cache_dir%/annotations" + serializer: { enable_annotations: true } \ No newline at end of file diff --git a/config/packages/nelmio_cors.yaml b/config/packages/nelmio_cors.yaml new file mode 100644 index 0000000000..c7665081f1 --- /dev/null +++ b/config/packages/nelmio_cors.yaml @@ -0,0 +1,10 @@ +nelmio_cors: + defaults: + origin_regex: true + allow_origin: ['%env(CORS_ALLOW_ORIGIN)%'] + allow_methods: ['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE'] + allow_headers: ['Content-Type', 'Authorization'] + expose_headers: ['Link'] + max_age: 3600 + paths: + '^/': null diff --git a/config/routes.yaml b/config/routes.yaml index 15180a086e..46ac47b1a0 100644 --- a/config/routes.yaml +++ b/config/routes.yaml @@ -22,10 +22,10 @@ oneup_uploader: resource: . type: uploader -resources: - type: rest - prefix: /api/{tool}/{type} - resource: Chamilo\CoreBundle\Controller\ResourceApiController +#resources: +# type: rest +# prefix: /api/{tool}/{type} +# resource: Chamilo\CoreBundle\Controller\ResourceApiController # Resources diff --git a/config/routes/api_platform.yaml b/config/routes/api_platform.yaml new file mode 100644 index 0000000000..38f11cba85 --- /dev/null +++ b/config/routes/api_platform.yaml @@ -0,0 +1,4 @@ +api_platform: + resource: . + type: api_platform + prefix: /api diff --git a/config/routes/sonata_api.yaml b/config/routes/sonata_api.yaml index 139c1fd1cf..e69de29bb2 100644 --- a/config/routes/sonata_api.yaml +++ b/config/routes/sonata_api.yaml @@ -1,58 +0,0 @@ -#NelmioApiDocBundle: -# resource: "@NelmioApiDocBundle/Resources/config/routing.yml" -# prefix: /doc - - #sonata_api_classification: - # type: rest - # prefix: /classification - # resource: "@SonataClassificationBundle/Resources/config/routing/api.xml" - # - #sonata_api_news: - # type: rest - # prefix: /news - # resource: "@SonataNewsBundle/Resources/config/routing/api.xml" - # - #sonata_api_media: - # type: rest - # prefix: /media - # resource: "@SonataMediaBundle/Resources/config/routing/api.xml" - # - #sonata_api_notification: - # type: rest - # prefix: /notification - # resource: "@SonataNotificationBundle/Resources/config/routing/api.xml" - -#sonata_api_ecommerce_product: -# type: rest -# prefix: /ecommerce -# resource: "@SonataProductBundle/Resources/config/routing/api.xml" -# -#sonata_api_ecommerce_order: -# type: rest -# prefix: /ecommerce -# resource: "@SonataOrderBundle/Resources/config/routing/api.xml" -# -#sonata_api_ecommerce_invoice: -# type: rest -# prefix: /ecommerce -# resource: "@SonataInvoiceBundle/Resources/config/routing/api.xml" -# -#sonata_api_ecommerce_customer: -# type: rest -# prefix: /ecommerce -# resource: "@SonataCustomerBundle/Resources/config/routing/api.xml" -# -#sonata_api_ecommerce_basket: -# type: rest -# prefix: /ecommerce -# resource: "@SonataBasketBundle/Resources/config/routing/api.xml" -# -#sonata_api_page: -# type: rest -# prefix: /page -# resource: "@SonataPageBundle/Resources/config/routing/api.xml" -# -#sonata_api_user: -# type: rest -# prefix: /user -# resource: "@SonataUserBundle/Resources/config/routing/api.xml"