Skip to content

Commit

Permalink
feat!: Upgraded to ApiPlatform 3.3 - requires config changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ambroisemaupate committed Jul 24, 2024
1 parent dc6d099 commit 0fce406
Show file tree
Hide file tree
Showing 18 changed files with 99 additions and 48 deletions.
Empty file removed .data/db_test/.gitkeep
Empty file.
Empty file removed .data/pgsql_test/.gitkeep
Empty file.
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
"ext-gd": "*",
"ext-iconv": "*",
"ext-json": "*",
"ext-mbstring": "*",
"ext-openssl": "*",
"ext-simplexml": "*",
"ext-mbstring": "*",
"ext-zip": "*",
"api-platform/core": "~3.2.14",
"api-platform/core": "~3.3.11",
"codercat/jwk-to-pem": "^1.0",
"composer/package-versions-deprecated": "1.11.99.3",
"doctrine/annotations": "^1.0",
Expand All @@ -46,7 +46,7 @@
"doctrine/orm": "~2.19.0",
"endroid/qr-code": "^4.0",
"enshrined/svg-sanitize": "^0.15",
"gedmo/doctrine-extensions": "^3.10.0",
"gedmo/doctrine-extensions": "^3.16.1",
"guzzlehttp/guzzle": "^7.2.0",
"guzzlehttp/psr7": "^2.0",
"inlinestyle/inlinestyle": "~1.2.7",
Expand All @@ -67,7 +67,7 @@
"psr/log": ">=1.1",
"ramsey/uuid": "^4.7",
"rezozero/intervention-request-bundle": "~3.0.0",
"rezozero/liform-bundle": "^0.19",
"rezozero/liform-bundle": "^0.20",
"rezozero/tree-walker": "^1.5.0",
"roadiz/nodetype-contracts": "~1.1.2",
"rollerworks/password-common-list": "^0.2.0",
Expand Down
1 change: 1 addition & 0 deletions config/api_resources/nodes_sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ resources:
groups:
- nodes_sources_base
- nodes_sources_default
- timestamps
- user
- urls
- tag_base
Expand Down
35 changes: 26 additions & 9 deletions config/packages/api_platform.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
parameters:
env(HTTP_CACHE_STALE_WHILE_REVALIDATE): 3600
env(HTTP_CACHE_MAX_AGE): 60
env(HTTP_CACHE_SHARED_MAX_AGE): 600

api_platform:
title: "%env(string:APP_TITLE)%"
description: "%env(string:APP_DESCRIPTION)%"
Expand All @@ -6,12 +11,23 @@ api_platform:
enable_re_doc: true
# Symfony inflector wrongly pluralizes "nodes_sources" to "nodes_sourcess"
keep_legacy_inflector: true
use_symfony_listeners: true
formats:
jsonld: ['application/ld+json']
json: ['application/json']
x-www-form-urlencoded: ['application/x-www-form-urlencoded']
docs_formats:
jsonld: ['application/ld+json']
jsonopenapi: ['application/vnd.openapi+json']
html: ['text/html']
patch_formats:
json: [ 'application/merge-patch+json' ]
graphql:
introspection: '%kernel.debug%'
graphiql:
enabled: false
graphql_playground:
enabled: true
enabled: false
show_webby: false
mapping:
paths:
Expand All @@ -21,15 +37,8 @@ api_platform:
- '%kernel.project_dir%/lib/RoadizUserBundle/src/Api/Dto'
- '%kernel.project_dir%/vendor/rezozero/tree-walker/src'
- '%kernel.project_dir%/config/api_resources'
patch_formats:
json: ['application/merge-patch+json']
swagger:
versions: [3]
collection:
pagination:
page_parameter_name: page
items_per_page_parameter_name: itemsPerPage

defaults:
stateless: true
extra_properties:
Expand All @@ -42,11 +51,19 @@ api_platform:
pagination_items_per_page: 15
pagination_maximum_items_per_page: 50
cache_headers:
# Automatically generate etags for API responses.
etag: true
public: true
# Default value for the response max age.
max_age: '%env(int:HTTP_CACHE_MAX_AGE)%'
# Default value for the response shared (proxy) max age.
shared_max_age: '%env(int:HTTP_CACHE_SHARED_MAX_AGE)%'
vary: [ 'Accept', 'Authorization', 'Origin', 'Accept-Encoding', 'Content-Type' ]
stale_while_revalidate: '%env(int:HTTP_CACHE_STALE_WHILE_REVALIDATE)%'
# Default values of the "Vary" HTTP header.
vary: ['Accept', 'Authorization', 'Origin', 'Accept-Encoding', 'Content-Type']
collection:
pagination:
items_per_page_parameter_name: itemsPerPage

when@prod:
api_platform:
Expand Down
2 changes: 2 additions & 0 deletions config/packages/framework.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ framework:
circular_reference_handler: 'RZ\Roadiz\CoreBundle\Serializer\CircularReferenceHandler'
max_depth_handler: 'RZ\Roadiz\CoreBundle\Serializer\CircularReferenceHandler'

handle_all_throwables: true

#esi: true
#fragments: true
php_errors:
Expand Down
1 change: 0 additions & 1 deletion config/packages/messenger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ framework:
messenger:
# Uncomment this (and the failed transport below) to send failed messages to this transport for later handling.
# failure_transport: failed
reset_on_message: true
transports:
# https://symfony.com/doc/current/messenger.html#transport-configuration
async:
Expand Down
2 changes: 1 addition & 1 deletion lib/EntityGenerator/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"squizlabs/php_codesniffer": "^3.5",
"phpstan/phpstan": "^1.5.3",
"phpunit/phpunit": "^9.5",
"api-platform/core": "~3.2.14"
"api-platform/core": "~3.3.11"
},
"extra": {
"branch-alias": {
Expand Down
6 changes: 3 additions & 3 deletions lib/RoadizCoreBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
"ext-zip": "*",
"ext-json": "*",
"ext-mbstring": "*",
"api-platform/core": "~3.2.14",
"api-platform/core": "~3.3.11",
"doctrine/annotations": "^1.0",
"doctrine/doctrine-bundle": "^2.8.1",
"doctrine/doctrine-migrations-bundle": "^3.1",
"doctrine/orm": "~2.19.0",
"gedmo/doctrine-extensions": "^3.10.0",
"gedmo/doctrine-extensions": "^3.16.1",
"inlinestyle/inlinestyle": "~1.2.7",
"james-heinrich/getid3": "^1.9",
"jms/serializer": "^3.9.0",
Expand All @@ -41,7 +41,7 @@
"phpoffice/phpspreadsheet": "^1.15",
"ramsey/uuid": "^4.7",
"rezozero/intervention-request-bundle": "~3.0.0",
"rezozero/liform-bundle": "^0.19",
"rezozero/liform-bundle": "^0.20",
"rezozero/tree-walker": "^1.5.0",
"roadiz/doc-generator": "2.4.x-dev",
"roadiz/documents": "2.4.x-dev",
Expand Down
71 changes: 51 additions & 20 deletions lib/RoadizCoreBundle/config/packages/api_platform.yaml
Original file line number Diff line number Diff line change
@@ -1,47 +1,78 @@
parameters:
env(HTTP_CACHE_STALE_WHILE_REVALIDATE): 3600
env(HTTP_CACHE_MAX_AGE): 60
env(HTTP_CACHE_SHARED_MAX_AGE): 600

api_platform:
patch_formats:
json: ['application/merge-patch+json']
enable_swagger_ui: false
title: "%env(string:APP_TITLE)%"
description: "%env(string:APP_DESCRIPTION)%"
version: '%env(string:APP_VERSION)%'
enable_swagger_ui: true
enable_re_doc: true
# Symfony inflector wrongly pluralizes "nodes_sources" to "nodes_sourcess"
keep_legacy_inflector: true
use_symfony_listeners: true
formats:
jsonld: ['application/ld+json']
json: ['application/json']
x-www-form-urlencoded: ['application/x-www-form-urlencoded']
docs_formats:
jsonld: ['application/ld+json']
jsonopenapi: ['application/vnd.openapi+json']
html: ['text/html']
patch_formats:
json: [ 'application/merge-patch+json' ]
graphql:
introspection: '%kernel.debug%'
graphiql:
enabled: false
graphql_playground:
enabled: false
show_webby: false
swagger:
versions: [3]
title: "%env(string:APP_TITLE)%"
description: "%env(string:APP_DESCRIPTION)%"
version: '%env(string:APP_VERSION)%'
mapping:
paths:
- '%kernel.project_dir%/src/Entity'
- '%kernel.project_dir%/src/GeneratedEntity'
- '%kernel.project_dir%/vendor/roadiz/core-bundle/src/Entity'
- '%kernel.project_dir%/vendor/rezozero/tree-walker/src'
- '%kernel.project_dir%/config/api_resources'

collection:
pagination:
page_parameter_name: page
items_per_page_parameter_name: itemsPerPage

http_cache:
invalidation:
enabled: true
varnish_urls: [ '%env(VARNISH_URL)%' ]

swagger:
versions: [3]
defaults:
stateless: true
extra_properties:
standard_put: true
rfc_7807_compliant_errors: false
enable_max_depth: true
normalization_context:
skip_null_values: true
pagination_client_items_per_page: true
pagination_items_per_page: 15
pagination_maximum_items_per_page: 50
cache_headers:
# Automatically generate etags for API responses.
etag: true
public: true
# Default value for the response max age.
max_age: '%env(int:HTTP_CACHE_MAX_AGE)%'
# Default value for the response shared (proxy) max age.
shared_max_age: '%env(int:HTTP_CACHE_SHARED_MAX_AGE)%'
vary: [ 'Accept', 'Authorization', 'Origin', 'Accept-Encoding', 'Content-Type' ]
stale_while_revalidate: '%env(int:HTTP_CACHE_STALE_WHILE_REVALIDATE)%'
# Default values of the "Vary" HTTP header.
vary: ['Accept', 'Authorization', 'Origin', 'Accept-Encoding', 'Content-Type']
collection:
pagination:
items_per_page_parameter_name: itemsPerPage

when@prod:
api_platform:
graphql:
introspection: false
graphiql:
enabled: false
graphql_playground:
enabled: false
http_cache:
invalidation:
enabled: true
varnish_urls: [ '%env(VARNISH_URL)%' ]
1 change: 1 addition & 0 deletions lib/RoadizCoreBundle/config/packages/framework.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ framework:
serializer:
circular_reference_handler: 'RZ\Roadiz\CoreBundle\Serializer\CircularReferenceHandler'
max_depth_handler: 'RZ\Roadiz\CoreBundle\Serializer\CircularReferenceHandler'
handle_all_throwables: true
csrf_protection:
enabled: true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace RZ\Roadiz\CoreBundle\Api\Controller;

use ApiPlatform\Api\IriConverterInterface;
use ApiPlatform\Exception\InvalidArgumentException;
use ApiPlatform\Exception\ResourceClassNotFoundException;
use ApiPlatform\Metadata\IriConverterInterface;
use ApiPlatform\Metadata\Exception\InvalidArgumentException;
use ApiPlatform\Metadata\Exception\ResourceClassNotFoundException;
use ApiPlatform\Metadata\Exception\OperationNotFoundException;
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
use Psr\Log\LoggerInterface;
Expand Down
2 changes: 1 addition & 1 deletion lib/RoadizCoreBundle/src/Api/Filter/ArchiveFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use ApiPlatform\Doctrine\Orm\Filter\AbstractFilter;
use ApiPlatform\Doctrine\Orm\Filter\DateFilter;
use ApiPlatform\Doctrine\Orm\Util\QueryNameGeneratorInterface;
use ApiPlatform\Exception\FilterValidationException;
use ApiPlatform\Metadata\Exception\FilterValidationException;
use ApiPlatform\Metadata\Operation;
use Doctrine\ORM\Query\Expr\Join;
use Doctrine\ORM\QueryBuilder;
Expand Down
2 changes: 1 addition & 1 deletion lib/RoadizCoreBundle/src/Api/Filter/IntersectionFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use ApiPlatform\Doctrine\Orm\Util\QueryNameGeneratorInterface;
use ApiPlatform\Doctrine\Orm\Filter\AbstractFilter;
use ApiPlatform\Exception\FilterValidationException;
use ApiPlatform\Metadata\Exception\FilterValidationException;
use ApiPlatform\Metadata\Operation;
use Doctrine\ORM\Query\Expr\Join;
use Doctrine\ORM\QueryBuilder;
Expand Down
2 changes: 1 addition & 1 deletion lib/RoadizCoreBundle/src/Api/Filter/LocaleFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace RZ\Roadiz\CoreBundle\Api\Filter;

use ApiPlatform\Doctrine\Orm\Util\QueryNameGeneratorInterface;
use ApiPlatform\Exception\FilterValidationException;
use ApiPlatform\Metadata\Exception\FilterValidationException;
use ApiPlatform\Metadata\Operation;
use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ManagerRegistry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace RZ\Roadiz\CoreBundle\EventSubscriber;

use ApiPlatform\Util\RequestAttributesExtractor;
use ApiPlatform\State\Util\RequestAttributesExtractor;
use RZ\Roadiz\CoreBundle\Api\Model\WebResponseInterface;
use RZ\Roadiz\CoreBundle\Entity\NodesSources;
use RZ\Roadiz\CoreBundle\Preview\PreviewResolverInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace RZ\Roadiz\CoreBundle\Serializer;

use ApiPlatform\Api\IriConverterInterface;
use ApiPlatform\Api\UrlGeneratorInterface;
use ApiPlatform\Metadata\IriConverterInterface;
use ApiPlatform\Metadata\UrlGeneratorInterface;

final class CircularReferenceHandler
{
Expand Down
2 changes: 1 addition & 1 deletion lib/RoadizUserBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"prefer-stable": true,
"require": {
"php": ">=8.1",
"api-platform/core": "~3.2.14",
"api-platform/core": "~3.3.11",
"doctrine/orm": "~2.19.0",
"roadiz/core-bundle": "2.4.x-dev",
"symfony/framework-bundle": "6.4.*",
Expand Down

0 comments on commit 0fce406

Please sign in to comment.