Skip to content

Commit

Permalink
feat: API Platform 4 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
priyadi committed Oct 29, 2024
1 parent 28bbf33 commit 8cd0ebc
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

# 0.19.0

* feat: API Platform 4 compatibility

# 0.18.1

* chore: add missing types
Expand Down
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"type": "library",
"require": {
"php": "^8.2",
"api-platform/core": "^3.2",
"api-platform/core": "^3.2 || ^4.0",
"doctrine/collections": "^2.2",
"doctrine/dbal": "^3.8 || ^4.0",
"doctrine/orm": "^2.19 || ^3.0 <3.3",
Expand All @@ -31,7 +31,9 @@
"twig/twig": "^3.8"
},
"require-dev": {
"composer-runtime-api": "^2.2",
"bnf/phpstan-psr-container": "^1.0",
"composer/semver": "^3.4",
"doctrine/doctrine-bundle": "^2.11.3",
"doctrine/doctrine-fixtures-bundle": "^3.5",
"doctrine/persistence": "^3.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/rekapager-api-platform/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"require": {
"php": "^8.2",
"api-platform/core": "^3.2",
"api-platform/core": "^3.2 || ^4.0",
"rekalogika/rekapager-contracts": "^0.18.1",
"rekalogika/rekapager-core": "^0.18.1",
"rekalogika/rekapager-doctrine-orm-adapter": "^0.18.1",
Expand Down
2 changes: 0 additions & 2 deletions tests/config/packages/api_platform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ api_platform:
rekapager_orm_enabled: true
normalization_context:
skip_null_values: false
event_listeners_backward_compatibility_layer: false
keep_legacy_inflector: false
mapping:
paths:
- '%kernel.project_dir%/src/App/Entity'
17 changes: 17 additions & 0 deletions tests/src/App/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
namespace Rekalogika\Rekapager\Tests\App;

use ApiPlatform\Symfony\Bundle\ApiPlatformBundle;
use Composer\InstalledVersions;
use Composer\Semver\VersionParser;
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
use Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle;
use Rekalogika\Rekapager\ApiPlatform\RekalogikaRekapagerApiPlatformBundle;
Expand Down Expand Up @@ -86,5 +88,20 @@ public function getConfigDir(): string
public function registerContainerConfiguration(LoaderInterface $loader): void
{
$this->baseRegisterContainerConfiguration($loader);

$loader->load(function (ContainerBuilder $container): void {
if (InstalledVersions::satisfies(new VersionParser(), 'api-platform/core', '3.*')) {
$container->loadFromExtension('api_platform', [
'event_listeners_backward_compatibility_layer' => false,
'keep_legacy_inflector' => false,
]);
} elseif (InstalledVersions::satisfies(new VersionParser(), 'api-platform/core', '4.*')) {
$container->loadFromExtension('api_platform', [
'serializer' => [
'hydra_prefix' => true,
],
]);
}
});
}
}

0 comments on commit 8cd0ebc

Please sign in to comment.