diff --git a/src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php b/src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php index 4596aa74b3..3e1d3fff03 100644 --- a/src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php +++ b/src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php @@ -50,6 +50,7 @@ use Doctrine\Persistence\ManagerRegistry; use PHPStan\PhpDocParser\Parser\PhpDocParser; use Ramsey\Uuid\Uuid; +use Symfony\Bundle\FrameworkBundle\Command\TranslationExtractCommand; use Symfony\Bundle\FrameworkBundle\Controller\ControllerHelper; use Symfony\Component\Config\FileLocator; use Symfony\Component\Config\Resource\DirectoryResource; @@ -177,7 +178,8 @@ public function load(array $configs, ContainerBuilder $container): void $this->registerLinkSecurityConfiguration($loader, $config); $this->registerJsonStreamerConfiguration($container, $loader, $formats, $config); - if (class_exists(ObjectMapper::class)) { + // TranslationExtractCommand was introduced in framework-bundle/7.3 with the object mapper service + if (class_exists(ObjectMapper::class) && class_exists(TranslationExtractCommand::class)) { $loader->load('state/object_mapper.php'); } $container->registerForAutoconfiguration(FilterInterface::class) diff --git a/tests/Functional/MappingTest.php b/tests/Functional/MappingTest.php index d697ae202d..28f68418c6 100644 --- a/tests/Functional/MappingTest.php +++ b/tests/Functional/MappingTest.php @@ -301,6 +301,10 @@ public function testGetSingleBookDto(): void $this->markTestSkipped('MongoDB not tested.'); } + if (!$this->getContainer()->has('api_platform.object_mapper')) { + $this->markTestSkipped('ObjectMapper not installed'); + } + $this->recreateSchema([Book::class]); $this->loadBookFixtures(); @@ -320,6 +324,10 @@ public function testGetCollectionBookDtoPaginated(): void $this->markTestSkipped('MongoDB not tested.'); } + if (!$this->getContainer()->has('api_platform.object_mapper')) { + $this->markTestSkipped('ObjectMapper not installed'); + } + $this->recreateSchema([Book::class]); $this->loadBookFixtures(); @@ -339,6 +347,10 @@ public function testGetCollectionBookDtoUnpaginated(): void $this->markTestSkipped('MongoDB not tested.'); } + if (!$this->getContainer()->has('api_platform.object_mapper')) { + $this->markTestSkipped('ObjectMapper not installed'); + } + $this->recreateSchema([Book::class]); $this->loadBookFixtures();