diff --git a/composer.json b/composer.json index e26d4bbf..8a50b2d7 100644 --- a/composer.json +++ b/composer.json @@ -54,8 +54,6 @@ "easycorp/easyadmin-bundle": "^4.3", "guzzlehttp/guzzle": "^7.4", "guzzlehttp/promises": "^1.5", - "jms/serializer": "^3.17", - "jms/serializer-bundle": "^4.0.2", "knplabs/knp-menu": "^3.3", "nelmio/api-doc-bundle": "^4.9", "nelmio/cors-bundle": "^2.2", diff --git a/composer.lock b/composer.lock index b86ee247..2a7f9bb0 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "50ce5d722e787dbef1d4f6f9e24096b4", + "content-hash": "1bfdf39e6cc26f32e58ba46bdbbfeea6", "packages": [ { "name": "composer/ca-bundle", @@ -1560,16 +1560,16 @@ }, { "name": "easycorp/easyadmin-bundle", - "version": "v4.15.1", + "version": "v4.16.1", "source": { "type": "git", "url": "https://github.com/EasyCorp/EasyAdminBundle.git", - "reference": "d0fb7e8260206d29154fbe3eddbc9cb5680a417b" + "reference": "e9e90f8659f9f8b508b46fe8d380ba28f6b6e498" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/EasyCorp/EasyAdminBundle/zipball/d0fb7e8260206d29154fbe3eddbc9cb5680a417b", - "reference": "d0fb7e8260206d29154fbe3eddbc9cb5680a417b", + "url": "https://api.github.com/repos/EasyCorp/EasyAdminBundle/zipball/e9e90f8659f9f8b508b46fe8d380ba28f6b6e498", + "reference": "e9e90f8659f9f8b508b46fe8d380ba28f6b6e498", "shasum": "" }, "require": { @@ -1596,6 +1596,7 @@ "symfony/translation": "^5.4|^6.0|^7.0", "symfony/twig-bundle": "^5.4|^6.0|^7.0", "symfony/uid": "^5.4|^6.0|^7.0", + "symfony/ux-twig-component": "^2.21", "symfony/validator": "^5.4|^6.0|^7.0" }, "require-dev": { @@ -1643,7 +1644,7 @@ ], "support": { "issues": "https://github.com/EasyCorp/EasyAdminBundle/issues", - "source": "https://github.com/EasyCorp/EasyAdminBundle/tree/v4.15.1" + "source": "https://github.com/EasyCorp/EasyAdminBundle/tree/v4.16.1" }, "funding": [ { @@ -1651,7 +1652,7 @@ "type": "github" } ], - "time": "2024-11-21T18:08:26+00:00" + "time": "2024-11-25T18:58:01+00:00" }, { "name": "egulias/email-validator", @@ -2173,255 +2174,6 @@ ], "time": "2024-07-18T11:15:46+00:00" }, - { - "name": "jms/metadata", - "version": "2.8.0", - "source": { - "type": "git", - "url": "https://github.com/schmittjoh/metadata.git", - "reference": "7ca240dcac0c655eb15933ee55736ccd2ea0d7a6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/metadata/zipball/7ca240dcac0c655eb15933ee55736ccd2ea0d7a6", - "reference": "7ca240dcac0c655eb15933ee55736ccd2ea0d7a6", - "shasum": "" - }, - "require": { - "php": "^7.2|^8.0" - }, - "require-dev": { - "doctrine/cache": "^1.0", - "doctrine/coding-standard": "^8.0", - "mikey179/vfsstream": "^1.6.7", - "phpunit/phpunit": "^8.5|^9.0", - "psr/container": "^1.0|^2.0", - "symfony/cache": "^3.1|^4.0|^5.0", - "symfony/dependency-injection": "^3.1|^4.0|^5.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.x-dev" - } - }, - "autoload": { - "psr-4": { - "Metadata\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Johannes M. Schmitt", - "email": "schmittjoh@gmail.com" - }, - { - "name": "Asmir Mustafic", - "email": "goetas@gmail.com" - } - ], - "description": "Class/method/property metadata management in PHP", - "keywords": [ - "annotations", - "metadata", - "xml", - "yaml" - ], - "support": { - "issues": "https://github.com/schmittjoh/metadata/issues", - "source": "https://github.com/schmittjoh/metadata/tree/2.8.0" - }, - "time": "2023-02-15T13:44:18+00:00" - }, - { - "name": "jms/serializer", - "version": "3.31.1", - "source": { - "type": "git", - "url": "https://github.com/schmittjoh/serializer.git", - "reference": "362503da26673f210221c25b99c795da718ad9aa" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/serializer/zipball/362503da26673f210221c25b99c795da718ad9aa", - "reference": "362503da26673f210221c25b99c795da718ad9aa", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.3.1 || ^2.0", - "doctrine/lexer": "^2.0 || ^3.0", - "jms/metadata": "^2.6", - "php": "^7.4 || ^8.0", - "phpstan/phpdoc-parser": "^1.20" - }, - "require-dev": { - "doctrine/annotations": "^1.14 || ^2.0", - "doctrine/coding-standard": "^12.0", - "doctrine/orm": "^2.14 || ^3.0", - "doctrine/persistence": "^2.5.2 || ^3.0", - "doctrine/phpcr-odm": "^1.5.2 || ^2.0", - "ext-pdo_sqlite": "*", - "jackalope/jackalope-doctrine-dbal": "^1.3", - "ocramius/proxy-manager": "^1.0 || ^2.0", - "phpbench/phpbench": "^1.0", - "phpstan/phpstan": "^1.10.57", - "phpunit/phpunit": "^9.0 || ^10.0 || ^11.0", - "psr/container": "^1.0 || ^2.0", - "rector/rector": "^1.0.0", - "symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0", - "symfony/expression-language": "^5.4 || ^6.0 || ^7.0", - "symfony/filesystem": "^5.4 || ^6.0 || ^7.0", - "symfony/form": "^5.4 || ^6.0 || ^7.0", - "symfony/translation": "^5.4 || ^6.0 || ^7.0", - "symfony/uid": "^5.4 || ^6.0 || ^7.0", - "symfony/validator": "^5.4 || ^6.0 || ^7.0", - "symfony/yaml": "^5.4 || ^6.0 || ^7.0", - "twig/twig": "^1.34 || ^2.4 || ^3.0" - }, - "suggest": { - "doctrine/collections": "Required if you like to use doctrine collection types as ArrayCollection.", - "symfony/cache": "Required if you like to use cache functionality.", - "symfony/uid": "Required if you'd like to serialize UID objects.", - "symfony/yaml": "Required if you'd like to use the YAML metadata format." - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.x-dev" - } - }, - "autoload": { - "psr-4": { - "JMS\\Serializer\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Johannes M. Schmitt", - "email": "schmittjoh@gmail.com" - }, - { - "name": "Asmir Mustafic", - "email": "goetas@gmail.com" - } - ], - "description": "Library for (de-)serializing data of any complexity; supports XML, and JSON.", - "homepage": "http://jmsyst.com/libs/serializer", - "keywords": [ - "deserialization", - "jaxb", - "json", - "serialization", - "xml" - ], - "support": { - "issues": "https://github.com/schmittjoh/serializer/issues", - "source": "https://github.com/schmittjoh/serializer/tree/3.31.1" - }, - "funding": [ - { - "url": "https://github.com/goetas", - "type": "github" - } - ], - "time": "2024-10-31T18:35:14+00:00" - }, - { - "name": "jms/serializer-bundle", - "version": "4.2.0", - "source": { - "type": "git", - "url": "https://github.com/schmittjoh/JMSSerializerBundle.git", - "reference": "d402554c66442ba494af7a37e3e43fc0f24e2689" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/JMSSerializerBundle/zipball/d402554c66442ba494af7a37e3e43fc0f24e2689", - "reference": "d402554c66442ba494af7a37e3e43fc0f24e2689", - "shasum": "" - }, - "require": { - "jms/metadata": "^2.5", - "jms/serializer": "^3.18", - "php": "^7.2 || ^8.0", - "symfony/dependency-injection": "^3.4 || ^4.0 || ^5.0 || ^6.0", - "symfony/framework-bundle": "^3.0 || ^4.0 || ^5.0 || ^6.0" - }, - "require-dev": { - "doctrine/coding-standard": "^8.1", - "doctrine/orm": "^2.4", - "phpunit/phpunit": "^8.0 || ^9.0", - "symfony/expression-language": "^3.0 || ^4.0 || ^5.0 || ^6.0", - "symfony/finder": "^3.0 || ^4.0 || ^5.0 || ^6.0", - "symfony/form": "^3.0 || ^4.0 || ^5.0 || ^6.0", - "symfony/stopwatch": "^3.0 || ^4.0 || ^5.0 || ^6.0", - "symfony/templating": "^3.0 || ^4.0 || ^5.0 || ^6.0", - "symfony/twig-bundle": "^3.0 || ^4.0 || ^5.0 || ^6.0", - "symfony/uid": "^5.1 || ^6.0", - "symfony/validator": "^3.0 || ^4.0 || ^5.0 || ^6.0", - "symfony/yaml": "^3.0 || ^4.0 || ^5.0 || ^6.0" - }, - "suggest": { - "jms/di-extra-bundle": "Required to get lazy loading (de)serialization visitors, ^1.3", - "symfony/expression-language": "Required for opcache preloading, ^3.0 || ^4.0 || ^5.0", - "symfony/finder": "Required for cache warmup, supported versions ^3.0|^4.0" - }, - "type": "symfony-bundle", - "extra": { - "branch-alias": { - "dev-master": "4.x-dev" - } - }, - "autoload": { - "psr-4": { - "JMS\\SerializerBundle\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Johannes M. Schmitt", - "email": "schmittjoh@gmail.com" - }, - { - "name": "Asmir Mustafic", - "email": "goetas@gmail.com" - } - ], - "description": "Allows you to easily serialize, and deserialize data of any complexity", - "homepage": "http://jmsyst.com/bundles/JMSSerializerBundle", - "keywords": [ - "deserialization", - "json", - "serialization", - "xml" - ], - "support": { - "issues": "https://github.com/schmittjoh/JMSSerializerBundle/issues", - "source": "https://github.com/schmittjoh/JMSSerializerBundle/tree/4.2.0" - }, - "funding": [ - { - "url": "https://github.com/goetas", - "type": "github" - } - ], - "time": "2022-09-13T19:27:18+00:00" - }, { "name": "knplabs/knp-components", "version": "v3.6.0", @@ -3314,30 +3066,30 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.33.0", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "82a311fd3690fb2bf7b64d5c98f912b3dd746140" + "reference": "c00d78fb6b29658347f9d37ebe104bffadf36299" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/82a311fd3690fb2bf7b64d5c98f912b3dd746140", - "reference": "82a311fd3690fb2bf7b64d5c98f912b3dd746140", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/c00d78fb6b29658347f9d37ebe104bffadf36299", + "reference": "c00d78fb6b29658347f9d37ebe104bffadf36299", "shasum": "" }, "require": { - "php": "^7.2 || ^8.0" + "php": "^7.4 || ^8.0" }, "require-dev": { "doctrine/annotations": "^2.0", - "nikic/php-parser": "^4.15", + "nikic/php-parser": "^5.3.0", "php-parallel-lint/php-parallel-lint": "^1.2", "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "^1.5", - "phpstan/phpstan-phpunit": "^1.1", - "phpstan/phpstan-strict-rules": "^1.0", - "phpunit/phpunit": "^9.5", + "phpstan/phpstan": "^2.0", + "phpstan/phpstan-phpunit": "^2.0", + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^9.6", "symfony/process": "^5.2" }, "type": "library", @@ -3355,9 +3107,9 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.33.0" + "source": "https://github.com/phpstan/phpdoc-parser/tree/2.0.0" }, - "time": "2024-10-13T11:25:22+00:00" + "time": "2024-10-13T11:29:49+00:00" }, { "name": "psr/cache", @@ -8214,6 +7966,89 @@ ], "time": "2024-09-25T14:18:03+00:00" }, + { + "name": "symfony/ux-twig-component", + "version": "v2.21.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/ux-twig-component.git", + "reference": "5b60b239fffcb04fc8bdb2a5a4001d19442d575d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/ux-twig-component/zipball/5b60b239fffcb04fc8bdb2a5a4001d19442d575d", + "reference": "5b60b239fffcb04fc8bdb2a5a4001d19442d575d", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "symfony/dependency-injection": "^5.4|^6.0|^7.0", + "symfony/deprecation-contracts": "^2.2|^3.0", + "symfony/event-dispatcher": "^5.4|^6.0|^7.0", + "symfony/property-access": "^5.4|^6.0|^7.0", + "twig/twig": "^3.8" + }, + "conflict": { + "symfony/config": "<5.4.0" + }, + "require-dev": { + "symfony/console": "^5.4|^6.0|^7.0", + "symfony/css-selector": "^5.4|^6.0|^7.0", + "symfony/dom-crawler": "^5.4|^6.0|^7.0", + "symfony/framework-bundle": "^5.4|^6.0|^7.0", + "symfony/phpunit-bridge": "^6.0|^7.0", + "symfony/stimulus-bundle": "^2.9.1", + "symfony/twig-bundle": "^5.4|^6.0|^7.0", + "symfony/webpack-encore-bundle": "^1.15" + }, + "type": "symfony-bundle", + "extra": { + "thanks": { + "name": "symfony/ux", + "url": "https://github.com/symfony/ux" + } + }, + "autoload": { + "psr-4": { + "Symfony\\UX\\TwigComponent\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Twig components for Symfony", + "homepage": "https://symfony.com", + "keywords": [ + "components", + "symfony-ux", + "twig" + ], + "support": { + "source": "https://github.com/symfony/ux-twig-component/tree/v2.21.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-10-05T22:11:16+00:00" + }, { "name": "symfony/validator", "version": "v6.4.15", diff --git a/config/bundles.php b/config/bundles.php index 618ffff6..bfe34ee8 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -8,7 +8,6 @@ Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true], Nelmio\ApiDocBundle\NelmioApiDocBundle::class => ['all' => true], - JMS\SerializerBundle\JMSSerializerBundle::class => ['all' => true], Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true], Nelmio\SecurityBundle\NelmioSecurityBundle::class => ['all' => true], @@ -21,4 +20,5 @@ Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true], T3G\Bundle\UsercentricsBundle\UsercentricsBundle::class => ['all' => true], EasyCorp\Bundle\EasyAdminBundle\EasyAdminBundle::class => ['all' => true], + Symfony\UX\TwigComponent\TwigComponentBundle::class => ['all' => true], ]; diff --git a/config/packages/jms_serializer.yaml b/config/packages/jms_serializer.yaml deleted file mode 100644 index 70d919e5..00000000 --- a/config/packages/jms_serializer.yaml +++ /dev/null @@ -1,33 +0,0 @@ -jms_serializer: - visitors: - xml_serialization: - format_output: '%kernel.debug%' - object_constructors: - doctrine: - fallback_strategy: "fallback" -# metadata: -# auto_detection: false -# directories: -# any-name: -# namespace_prefix: "My\\FooBundle" -# path: "@MyFooBundle/Resources/config/serializer" -# another-name: -# namespace_prefix: "My\\BarBundle" -# path: "@MyBarBundle/Resources/config/serializer" - -when@prod: - jms_serializer: - visitors: - json_serialization: - options: - - JSON_UNESCAPED_SLASHES - - JSON_PRESERVE_ZERO_FRACTION - -when@dev: - jms_serializer: - visitors: - json_serialization: - options: - - JSON_PRETTY_PRINT - - JSON_UNESCAPED_SLASHES - - JSON_PRESERVE_ZERO_FRACTION diff --git a/config/packages/serializer.yaml b/config/packages/serializer.yaml new file mode 100644 index 00000000..b704a8fa --- /dev/null +++ b/config/packages/serializer.yaml @@ -0,0 +1,4 @@ +# config/packages/serializer.yaml +framework: + serializer: + name_converter: 'serializer.name_converter.camel_case_to_snake_case' diff --git a/config/packages/twig_component.yaml b/config/packages/twig_component.yaml new file mode 100644 index 00000000..fd17ac69 --- /dev/null +++ b/config/packages/twig_component.yaml @@ -0,0 +1,5 @@ +twig_component: + anonymous_template_directory: 'components/' + defaults: + # Namespace & directory for components + App\Twig\Components\: 'components/' diff --git a/src/Controller/Api/AbstractController.php b/src/Controller/Api/AbstractController.php index fbbe0dad..880183e4 100644 --- a/src/Controller/Api/AbstractController.php +++ b/src/Controller/Api/AbstractController.php @@ -33,9 +33,9 @@ use Doctrine\Inflector\InflectorFactory; use Doctrine\ORM\Mapping\ClassMetadataInfo; use Doctrine\Persistence\ManagerRegistry; -use JMS\Serializer\SerializerInterface; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +use Symfony\Component\Serializer\SerializerInterface; use Symfony\Component\Validator\ConstraintViolationInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; use Symfony\Contracts\Cache\TagAwareCacheInterface; diff --git a/src/Controller/Api/MajorVersion/ReleasesController.php b/src/Controller/Api/MajorVersion/ReleasesController.php index 9c656af2..134857c1 100644 --- a/src/Controller/Api/MajorVersion/ReleasesController.php +++ b/src/Controller/Api/MajorVersion/ReleasesController.php @@ -25,12 +25,12 @@ use App\Controller\Api\AbstractController; use App\Entity\Release; -use JMS\Serializer\SerializationContext; use Nelmio\ApiDocBundle\Annotation\Model; use OpenApi\Annotations as OA; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; +use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; use Symfony\Contracts\Cache\ItemInterface; #[Route(path: ['/api/v1/major/{version}/release', '/v1/api/major/{version}/release'], defaults: ['_format' => 'json'])] @@ -73,7 +73,9 @@ public function getReleasesByMajorVersion(string $version): JsonResponse return $this->getSerializer()->serialize( $majorVersion->getReleases(), 'json', - SerializationContext::create()->setGroups(['data']) + [ + AbstractNormalizer::GROUPS => ['data'], + ] ); }); @@ -113,7 +115,9 @@ public function getLatestReleaseByMajorVersion(string $version): JsonResponse return $this->getSerializer()->serialize( $majorVersion->getLatestRelease(), 'json', - SerializationContext::create()->setGroups(['data']) + [ + AbstractNormalizer::GROUPS => ['data'], + ] ); }); @@ -160,7 +164,9 @@ public function getLatestSecurityReleaseByMajorVersion(string $version): JsonRes $json = $this->getSerializer()->serialize( $release, 'json', - SerializationContext::create()->setGroups(['data']) + [ + AbstractNormalizer::GROUPS => ['data'], + ] ); } @@ -204,7 +210,9 @@ public function getLatestReleaseContentByMajorVersion(string $version): JsonResp return $this->getSerializer()->serialize( $majorVersion->getLatestRelease(), 'json', - SerializationContext::create()->setGroups(['content']) + [ + AbstractNormalizer::GROUPS => ['content'], + ] ); }); diff --git a/src/Controller/Api/MajorVersion/RequirementsController.php b/src/Controller/Api/MajorVersion/RequirementsController.php index fd4441b3..c0deb504 100644 --- a/src/Controller/Api/MajorVersion/RequirementsController.php +++ b/src/Controller/Api/MajorVersion/RequirementsController.php @@ -25,7 +25,6 @@ use App\Controller\Api\AbstractController; use App\Entity\Requirement; -use JMS\Serializer\SerializationContext; use Nelmio\ApiDocBundle\Annotation\Model; use Nelmio\ApiDocBundle\Annotation\Security; use OpenApi\Annotations as OA; @@ -37,6 +36,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; +use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; use Symfony\Contracts\Cache\ItemInterface; #[Route( @@ -86,7 +86,9 @@ public function getRequirementsByMajorVersion(string $version): JsonResponse return $this->getSerializer()->serialize( $requirements, 'json', - SerializationContext::create()->setGroups(['data']) + [ + AbstractNormalizer::GROUPS => ['data'], + ] ); }); @@ -246,7 +248,9 @@ public function updateRequirement(string $version, Request $request): JsonRespon $json = $this->getSerializer()->serialize( $requirement, 'json', - SerializationContext::create()->setGroups(['content']) + [ + AbstractNormalizer::GROUPS => ['content'], + ] ); return new JsonResponse($json, Response::HTTP_OK, [], true); } diff --git a/src/Controller/Api/MajorVersionController.php b/src/Controller/Api/MajorVersionController.php index 86ccf6dd..f4f3bd92 100644 --- a/src/Controller/Api/MajorVersionController.php +++ b/src/Controller/Api/MajorVersionController.php @@ -24,7 +24,6 @@ namespace App\Controller\Api; use App\Entity\MajorVersion; -use JMS\Serializer\SerializationContext; use Nelmio\ApiDocBundle\Annotation\Model; use Nelmio\ApiDocBundle\Annotation\Security; use OpenApi\Annotations as OA; @@ -36,6 +35,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; +use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; use Symfony\Contracts\Cache\ItemInterface; #[Route(path: ['/api/v1/major', '/v1/api/major'], defaults: ['_format' => 'json'])] @@ -68,7 +68,9 @@ public function getMajorReleases(): JsonResponse return $this->getSerializer()->serialize( $majors, 'json', - SerializationContext::create()->setGroups(['content']) + [ + AbstractNormalizer::GROUPS => ['content'], + ] ); }); @@ -112,7 +114,9 @@ public function getMajorRelease(string $version): JsonResponse return $this->getSerializer()->serialize( $majorVersion, 'json', - SerializationContext::create()->setGroups(['content']) + [ + AbstractNormalizer::GROUPS => ['content'], + ] ); }); @@ -249,7 +253,9 @@ public function updateMajorRelease(string $version, Request $request): JsonRespo $json = $this->getSerializer()->serialize( $entity, 'json', - SerializationContext::create()->setGroups(['content']) + [ + AbstractNormalizer::GROUPS => ['content'], + ] ); return new JsonResponse($json, Response::HTTP_OK, [], true); } diff --git a/src/Controller/Api/ReleaseController.php b/src/Controller/Api/ReleaseController.php index 6e2b1b88..23dd3bdd 100644 --- a/src/Controller/Api/ReleaseController.php +++ b/src/Controller/Api/ReleaseController.php @@ -25,7 +25,6 @@ use App\Entity\Embeddables\ReleaseNotes; use App\Entity\Release; -use JMS\Serializer\SerializationContext; use Nelmio\ApiDocBundle\Annotation\Model; use Nelmio\ApiDocBundle\Annotation\Security; use OpenApi\Annotations as OA; @@ -37,6 +36,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; +use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; use Symfony\Contracts\Cache\ItemInterface; #[Route(path: ['/api/v1/release', '/v1/api/release'], defaults: ['_format' => 'json'])] @@ -92,7 +92,9 @@ public function getRelease(?string $version): JsonResponse return $this->getSerializer()->serialize( $releases, 'json', - SerializationContext::create()->setGroups(['data']) + [ + AbstractNormalizer::GROUPS => ['data'], + ] ); }); @@ -272,7 +274,9 @@ public function getContentForVersion(string $version): JsonResponse return $this->getSerializer()->serialize( $release, 'json', - SerializationContext::create()->setGroups(['content']) + [ + AbstractNormalizer::GROUPS => ['content'], + ] ); }); @@ -336,7 +340,9 @@ public function updateRelease(string $version, Request $request): JsonResponse $json = $this->getSerializer()->serialize( $release, 'json', - SerializationContext::create()->setGroups(['data', 'content']) + [ + AbstractNormalizer::GROUPS => ['data', 'content'], + ] ); return new JsonResponse($json, Response::HTTP_OK, [], true); } diff --git a/src/Controller/Api/SitepackageController.php b/src/Controller/Api/SitepackageController.php index c90d04d2..a18850bf 100644 --- a/src/Controller/Api/SitepackageController.php +++ b/src/Controller/Api/SitepackageController.php @@ -26,7 +26,6 @@ use App\Entity\Sitepackage; use App\Service\SitepackageGenerator; use App\Utility\StringUtility; -use JMS\Serializer\SerializerInterface; use Nelmio\ApiDocBundle\Annotation\Model; use OpenApi\Attributes as OA; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; @@ -35,6 +34,7 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\Routing\Attribute\Route; +use Symfony\Component\Serializer\SerializerInterface; use Symfony\Component\Validator\ConstraintViolationInterface; use Symfony\Component\Validator\Validation; diff --git a/src/DataFixtures/MajorVersionFixtures.php b/src/DataFixtures/MajorVersionFixtures.php index 3baf4073..97abdb14 100644 --- a/src/DataFixtures/MajorVersionFixtures.php +++ b/src/DataFixtures/MajorVersionFixtures.php @@ -25,7 +25,6 @@ use App\Entity\MajorVersion; use Doctrine\Bundle\FixturesBundle\Fixture; -use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Persistence\ObjectManager; use Faker\Factory as FakerFactory; @@ -98,97 +97,71 @@ protected function getData(): iterable yield new MajorVersionFixturesData( self::MAJOR_VERSION_SPRINT, new MajorVersion( - 10, - 'TYPO3 10', - $faker->sentence(6) . '[SUBTITLE]', - $faker->paragraph(3) . '[DESCRIPTION]', - $today, - null, - null, - null, - new ArrayCollection(), - new ArrayCollection(), - null + version: 10, + title: 'TYPO3 10', + subtitle: $faker->sentence(6) . '[SUBTITLE]', + description: $faker->paragraph(3) . '[DESCRIPTION]', + releaseDate: $today ) ); yield new MajorVersionFixturesData( self::MAJOR_VERSION_LTS, new MajorVersion( - 9, - 'TYPO3 9', - $faker->sentence(6) . '[SUBTITLE]', - $faker->paragraph(3) . '[DESCRIPTION]', - $today, - null, - $today->modify('+3 years')->modify('-1 day'), - null, - new ArrayCollection(), - new ArrayCollection(), - 9.5 + version: 9, + title: 'TYPO3 9', + subtitle: $faker->sentence(6) . '[SUBTITLE]', + description: $faker->paragraph(3) . '[DESCRIPTION]', + releaseDate: $today, + maintainedUntil: $today->modify('+3 years')->modify('-1 day'), + lts: 9.5 ) ); yield new MajorVersionFixturesData( self::MAJOR_VERSION_LTS_OLD, new MajorVersion( - 8, - 'TYPO3 8', - $faker->sentence(6) . '[SUBTITLE]', - $faker->paragraph(3) . '[DESCRIPTION]', - $today->modify('-1 years'), - null, - $today->modify('+2 years')->modify('-1 day'), - null, - new ArrayCollection(), - new ArrayCollection(), - 8.7 + version: 8, + title: 'TYPO3 8', + subtitle: $faker->sentence(6) . '[SUBTITLE]', + description: $faker->paragraph(3) . '[DESCRIPTION]', + releaseDate: $today->modify('-1 years'), + maintainedUntil: $today->modify('+2 years')->modify('-1 day'), + lts: 8.7 ) ); yield new MajorVersionFixturesData( self::MAJOR_VERSION_ELTS, new MajorVersion( - 7, - 'TYPO3 7', - $faker->sentence(6) . '[SUBTITLE]', - $faker->paragraph(3) . '[DESCRIPTION]', - $today->modify('-3 years'), - null, - $today->modify('-1 day'), - null, - new ArrayCollection(), - new ArrayCollection(), - 7.6 + version: 7, + title: 'TYPO3 7', + subtitle: $faker->sentence(6) . '[SUBTITLE]', + description: $faker->paragraph(3) . '[DESCRIPTION]', + releaseDate: $today->modify('-3 years'), + maintainedUntil: $today->modify('-1 day'), + lts: 7.6 ) ); yield new MajorVersionFixturesData( self::MAJOR_VERSION_ELTS_EXT, new MajorVersion( - 6.2, - 'TYPO3 6.2', - $faker->sentence(6) . '[SUBTITLE]', - $faker->paragraph(3) . '[DESCRIPTION]', - $today->modify('-3 years'), - null, - $today->modify('-1 day'), - $today->modify('-1 day')->modify('+4 years'), - new ArrayCollection(), - new ArrayCollection(), - 6.2 + version: 6.2, + title: 'TYPO3 6.2', + subtitle: $faker->sentence(6) . '[SUBTITLE]', + description: $faker->paragraph(3) . '[DESCRIPTION]', + releaseDate: $today->modify('-3 years'), + maintainedUntil: $today->modify('-1 day'), + eltsUntil: $today->modify('-1 day')->modify('+4 years'), + lts: 6.2 ) ); yield new MajorVersionFixturesData( self::MAJOR_VERSION_OUTDATED, new MajorVersion( - 4.5, - 'TYPO3 4.5', - $faker->sentence(6) . '[SUBTITLE]', - $faker->paragraph(3) . '[DESCRIPTION]', - $today->modify('-6 years'), - null, - $today->modify('-3 years')->modify('-1 day'), - null, - new ArrayCollection(), - new ArrayCollection(), - null + version: 4.5, + title: 'TYPO3 4.5', + subtitle: $faker->sentence(6) . '[SUBTITLE]', + description: $faker->paragraph(3) . '[DESCRIPTION]', + releaseDate: $today->modify('-6 years'), + maintainedUntil: $today->modify('-3 years')->modify('-1 day') ) ); } diff --git a/src/Entity/Embeddables/Package.php b/src/Entity/Embeddables/Package.php index 9db4755c..5f1826bf 100644 --- a/src/Entity/Embeddables/Package.php +++ b/src/Entity/Embeddables/Package.php @@ -24,37 +24,28 @@ namespace App\Entity\Embeddables; use Doctrine\ORM\Mapping as ORM; -use JMS\Serializer\Annotation as Serializer; -use OpenApi\Annotations as OA; +use OpenApi\Attributes as OA; +use Symfony\Component\Serializer\Attribute\Groups; use Symfony\Component\Validator\Constraints as Assert; #[ORM\Embeddable] class Package implements \JsonSerializable { public function __construct( - /** - * @OA\Property(example="23cab7d353b055a3bf5ef8f9963ba348") - */ + #[OA\Property(example: '23cab7d353b055a3bf5ef8f9963ba348')] #[Assert\Regex('/^[0-9a-f]{32}$/')] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, nullable: true)] - #[Serializer\Groups(['data'])] - #[Serializer\Type('string')] + #[Groups(['data'])] private ?string $md5sum, - /** - * @OA\Property(example="7af3a3fe4f1bbda916575c9779368d229d259819") - */ + #[OA\Property(example: '7af3a3fe4f1bbda916575c9779368d229d259819')] #[Assert\Regex('/^[0-9a-f]{40}$/')] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, nullable: true)] - #[Serializer\Groups(['data'])] - #[Serializer\Type('string')] + #[Groups(['data'])] private ?string $sha1sum, - /** - * @OA\Property(example="1e34187712269aa556413d2529b950c0dbff17cc95160cf316de07a3c85ce859") - */ + #[OA\Property(example: '1e34187712269aa556413d2529b950c0dbff17cc95160cf316de07a3c85ce859')] #[Assert\Regex('/^[A-Fa-f0-9]{64}$/')] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, nullable: true)] - #[Serializer\Groups(['data'])] - #[Serializer\Type('string')] + #[Groups(['data'])] private ?string $sha256sum ) {} diff --git a/src/Entity/Embeddables/ReleaseNotes.php b/src/Entity/Embeddables/ReleaseNotes.php index 1e9121ba..c77e56a7 100644 --- a/src/Entity/Embeddables/ReleaseNotes.php +++ b/src/Entity/Embeddables/ReleaseNotes.php @@ -24,48 +24,36 @@ namespace App\Entity\Embeddables; use Doctrine\ORM\Mapping as ORM; -use JMS\Serializer\Annotation as Serializer; -use OpenApi\Annotations as OA; +use OpenApi\Attributes as OA; +use Symfony\Component\Serializer\Attribute\Groups; use Symfony\Component\Validator\Constraints as Assert; #[ORM\Embeddable] class ReleaseNotes { - /** - * @OA\Property(type="string", format="uri", example="https://typo3.org/news/article/typo3-v910-released") - */ + #[OA\Property(format: 'uri', example: 'https://typo3.org/news/article/typo3-v910-released')] #[Assert\Url] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, nullable: true)] - #[Serializer\Groups(['putcontent', 'content'])] - #[Serializer\Type('string')] + #[Groups(['putcontent', 'content'])] private ?string $newsLink = null; - /** - * @OA\Property(example="This release is a bugfix and regression fix release.", description="Short news text about the release.") - */ + #[OA\Property(example: 'This release is a bugfix and regression fix release.", description="Short news text about the release.')] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: true)] - #[Serializer\Groups(['putcontent', 'content'])] - #[Serializer\Type('string')] + #[Groups(['putcontent', 'content'])] private ?string $news = null; - /** - * @OA\Property(description="Ugrade instructions - supports markdown (github flavored)", example="The [usual upgrading procedure](https:\/\/docs.typo3.org\/upgrade) applies.\nNo database updates are necessary.\n") - */ + #[OA\Property(description: 'Ugrade instructions - supports markdown (github flavored)', example: 'The [usual upgrading procedure](https:\/\/docs.typo3.org\/upgrade) applies.\nNo database updates are necessary.\n')] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: true)] - #[Serializer\Groups(['putcontent', 'content'])] - #[Serializer\Type('string')] + #[Groups(['putcontent', 'content'])] private ?string $upgradingInstructions = null; - /** - * @OA\Property(description="Changelog as markdown") - */ + #[OA\Property(description: 'Changelog as markdown')] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: true)] - #[Serializer\Groups(['putcontent', 'content'])] - #[Serializer\Type('string')] + #[Groups(['putcontent', 'content'])] private ?string $changes = null; #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: true)] - #[Serializer\Groups(['content'])] + #[Groups(['content'])] private ?string $legacyContent = null; public function setNewsLink(string $newsLink): void diff --git a/src/Entity/MajorVersion.php b/src/Entity/MajorVersion.php index cc142c2b..2042c8ed 100644 --- a/src/Entity/MajorVersion.php +++ b/src/Entity/MajorVersion.php @@ -29,45 +29,101 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; -use JMS\Serializer\Annotation as Serializer; -use OpenApi\Annotations as OA; - -/** - * @OA\Schema( - * description="TYPO3 major version", - * title="Major version", - * ) - */ +use OpenApi\Attributes as OA; +use Symfony\Component\Serializer\Attribute\Context; +use Symfony\Component\Serializer\Attribute\Groups; +use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer; +use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; + +#[OA\Schema(description: 'TYPO3 major version', title: 'Major version')] #[ORM\Entity(repositoryClass: MajorVersionRepository::class)] #[ORM\EntityListeners([MajorVersionListener::class])] class MajorVersion implements \JsonSerializable, \Stringable { - /** - * For example 7 or 8 or 4.3. - * - * @OA\Property(example="8") - */ + #[OA\Property(example: 8)] #[ORM\Id] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT)] - #[Serializer\Groups(['data', 'content', 'patch'])] + #[Groups(['data', 'content', 'patch'])] + #[Context([ObjectNormalizer::DISABLE_TYPE_ENFORCEMENT => true])] private float $version; + #[OA\Property(type: 'string', example: 'TYPO3 8 LTS')] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] + #[Groups(['data', 'content', 'patch'])] + private string $title; + + #[OA\Property(example: 'The current stable LTS release (for all new projects)')] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] + #[Groups(['content', 'patch'])] + private string $subtitle; + + #[OA\Property(example: 'The latest version with Long Term Support (LTS). It will have full support until October 2018 and security bugfixes until March 2020.')] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] + #[Groups(['content', 'patch'])] + private string $description; + + #[OA\Property(example: '2017-12-12T16:48:22+00:00')] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE)] + #[Groups(['data', 'content', 'patch'])] + #[Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\\TH:i:sP'])] + private \DateTimeImmutable $releaseDate; + + #[OA\Property(example: '2017-12-12T16:48:22+00:00')] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: true)] + #[Groups(['data', 'content', 'patch'])] + #[Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\\TH:i:sP'])] + private ?\DateTimeImmutable $regularMaintenanceUntil; + + #[OA\Property(example: '2017-12-12T16:48:22+00:00')] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: true)] + #[Groups(['data', 'content', 'patch'])] + #[Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\\TH:i:sP'])] + private ?\DateTimeImmutable $maintainedUntil; + + #[OA\Property(example: '2017-12-12T16:48:22+00:00')] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: true)] + #[Groups(['data', 'content', 'patch'])] + #[Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\\TH:i:sP'])] + private ?\DateTimeImmutable $eltsUntil; + + /** + * @var Collection + */ + #[ORM\OneToMany( + targetEntity: Requirement::class, + mappedBy: 'version', + cascade: ['persist', 'remove'], + orphanRemoval: true + )] + #[Groups(['data', 'content'])] + private Collection $requirements; + + /** + * @var Collection + */ + #[ORM\OneToMany( + targetEntity: Release::class, + mappedBy: 'majorVersion', + cascade: ['persist', 'remove'], + orphanRemoval: true + )] + #[Groups(['data'])] + private Collection $releases; + + #[OA\Property(example: 8.7)] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT, nullable: true)] + #[Groups(['data', 'content', 'patch'])] + private ?float $lts = null; + public static function create(float $version = 0.0): self { $now = (new \DateTimeImmutable())->setTime(0, 0, 0); - $emptyCollection = new ArrayCollection(); return new self( $version, sprintf('TYPO3 %d', $version), 'The upcoming LTS release (for new projects)', 'The development of the next major version', - $now, - null, - null, - null, - $emptyCollection, - $emptyCollection, - null, + $now ); } @@ -77,92 +133,36 @@ public static function create(float $version = 0.0): self */ public function __construct( float $version, - /** - * TYPO3 7 LTS. - * - * @OA\Property(example="TYPO3 8 LTS") - */ - #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] - #[Serializer\Groups(['data', 'content', 'patch'])] - private string $title, - /** - * @OA\Property(example="The current stable LTS release (for all new projects)") - */ - #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] - #[Serializer\Groups(['content', 'patch'])] - private string $subtitle, - /** - * @OA\Property(example="The latest version with Long Term Support (LTS). It will have full support until October 2018 and security bugfixes until March 2020.") - */ - #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] - #[Serializer\Groups(['content', 'patch'])] - private string $description, - /** - * @OA\Property(example="2017-12-12T16:48:22+00:00") - */ - #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE)] - #[Serializer\Groups(['data', 'content', 'patch'])] - #[Serializer\Type("DateTimeImmutable<'Y-m-d\\TH:i:sP'>")] - private \DateTimeImmutable $releaseDate, - /** - * @OA\Property(example="2017-12-12T16:48:22+00:00") - * - * @todo `regularMaintenanceUntil` seems to be unused - */ - #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: true)] - #[Serializer\Groups(['data', 'content', 'patch'])] - #[Serializer\Type("DateTimeImmutable<'Y-m-d\\TH:i:sP'>")] - private ?\DateTimeImmutable $regularMaintenanceUntil, - /** - * @OA\Property(example="2017-12-12T16:48:22+00:00") - */ - #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: true)] - #[Serializer\Groups(['data', 'content', 'patch'])] - #[Serializer\Type("DateTimeImmutable<'Y-m-d\\TH:i:sP'>")] - private ?\DateTimeImmutable $maintainedUntil, - /** - * @OA\Property(example="2017-12-12T16:48:22+00:00") - */ - #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: true)] - #[Serializer\Groups(['data', 'content', 'patch'])] - #[Serializer\Type("DateTimeImmutable<'Y-m-d\\TH:i:sP'>")] - private ?\DateTimeImmutable $eltsUntil, - /** - * @var Collection - */ - #[ORM\OneToMany( - targetEntity: Requirement::class, - mappedBy: 'version', - cascade: ['persist', 'remove'], - orphanRemoval: true - )] - #[Serializer\Groups(['data', 'content'])] - #[Serializer\Type('ArrayCollection')] - private Collection $requirements, - /** - * @var Collection - */ - #[ORM\OneToMany( - targetEntity: Release::class, - mappedBy: 'majorVersion', - cascade: ['persist', 'remove'], - orphanRemoval: true - )] - #[Serializer\Type('ArrayCollection')] - #[Serializer\Groups(['data'])] - private Collection $releases, - /** - * @OA\Property(example=8.7) - */ - #[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT, nullable: true)] - #[Serializer\Groups(['data', 'content', 'patch'])] - private ?float $lts, + string $title, + string $subtitle, + string $description, + \DateTimeImmutable $releaseDate, + ?\DateTimeImmutable $regularMaintenanceUntil = null, + ?\DateTimeImmutable $maintainedUntil = null, + ?\DateTimeImmutable $eltsUntil = null, + ?Collection $requirements = null, + ?Collection $releases = null, + ?float $lts = null ) { $this->setVersion($version); + $this->setTitle($title); + $this->setSubtitle($subtitle); + $this->setDescription($description); + $this->setReleaseDate($releaseDate); + $this->setRegularMaintenanceUntil($regularMaintenanceUntil); + $this->setMaintainedUntil($maintainedUntil); + $this->setEltsUntil($eltsUntil); + $this->setRequirements($requirements ?? new ArrayCollection()); + $this->setReleases($releases ?? new ArrayCollection()); + $this->setLts($lts); } - public function setVersion(float $version): void + public function setVersion(float|string $version): void { + if (is_string($version)) { + $version = (float)$version; + } + $this->version = (float)VersionUtility::extractMajorVersionNumber((string)$version); } diff --git a/src/Entity/Release.php b/src/Entity/Release.php index cd419143..d5c87709 100644 --- a/src/Entity/Release.php +++ b/src/Entity/Release.php @@ -29,66 +29,48 @@ use App\EventListener\ReleaseListener; use App\Repository\ReleaseRepository; use Doctrine\ORM\Mapping as ORM; -use JMS\Serializer\Annotation as Serializer; -use OpenApi\Annotations as OA; +use OpenApi\Attributes as OA; +use Symfony\Component\Serializer\Attribute\Groups; use Symfony\Component\Validator\Constraints as Assert; -/** - * @OA\Schema( - * description="TYPO3 release", - * title="Release", - * ) - */ +#[OA\Schema(description: 'TYPO3 release', title: 'Release')] #[ORM\Entity(repositoryClass: ReleaseRepository::class)] #[ORM\EntityListeners([ReleaseListener::class])] class Release implements \JsonSerializable, \Stringable { - /** - * Version in a semver/version_compare compatible format. - * - * @OA\Property(example="8.7.12") - */ + #[OA\Property(example: '8.7.12')] #[Assert\Regex( '/^(\d+\.\d+\.\d+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/' )] #[ORM\Id] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] - #[Serializer\Groups(['content', 'data'])] + #[Groups(['content', 'data'])] private string $version; - /** - * @OA\Property(example="2017-12-12T16:48:22+00:00") - * - * @var \DateTime|\DateTimeImmutable - */ + #[OA\Property(example: '2017-12-12T16:48:22+00:00')] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_MUTABLE)] - #[Serializer\Groups(['data', 'content'])] - #[Serializer\Type("DateTime<'Y-m-d\\TH:i:sP'>")] + #[Groups(['data', 'content'])] private \DateTimeInterface $date; #[Assert\Choice(callback: [ReleaseTypeEnum::class, 'getAvailableOptions'])] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] - #[Serializer\Groups(['data'])] + #[Groups(['data'])] private string $type; - /** - * @OA\Property(example="true") - */ + #[OA\Property(example: true)] #[Assert\Type('boolean')] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, options: ['default' => 0])] - #[Serializer\Groups(['data', 'content'])] + #[Groups(['data', 'content'])] private bool $elts = false; #[Assert\Valid] #[ORM\Embedded(class: Package::class)] - #[Serializer\Type(\App\Entity\Embeddables\Package::class)] - #[Serializer\Groups(['data'])] + #[Groups(['data'])] private Package $tarPackage; #[Assert\Valid] #[ORM\Embedded(class: Package::class)] - #[Serializer\Type(\App\Entity\Embeddables\Package::class)] - #[Serializer\Groups(['data'])] + #[Groups(['data'])] private Package $zipPackage; #[Assert\Valid] @@ -99,8 +81,7 @@ class Release implements \JsonSerializable, \Stringable #[Assert\Valid] #[ORM\Embedded(class: ReleaseNotes::class)] - #[Serializer\Type(\App\Entity\Embeddables\ReleaseNotes::class)] - #[Serializer\Groups(['content', 'putcontent'])] + #[Groups(['content', 'putcontent'])] private ReleaseNotes $releaseNotes; public function setVersion(string $version): void diff --git a/src/Entity/Requirement.php b/src/Entity/Requirement.php index 70c8e83f..e365b98a 100644 --- a/src/Entity/Requirement.php +++ b/src/Entity/Requirement.php @@ -27,16 +27,11 @@ use App\EventListener\RequirementListener; use App\Repository\RequirementRepository; use Doctrine\ORM\Mapping as ORM; -use JMS\Serializer\Annotation as Serializer; -use OpenApi\Annotations as OA; +use OpenApi\Attributes as OA; +use Symfony\Component\Serializer\Attribute\Groups; use Symfony\Component\Validator\Constraints as Assert; -/** - * @OA\Schema( - * description="TYPO3 major version requirement", - * title="Requirement", - * ) - */ +#[OA\Schema(description: 'TYPO3 major version requirement', title: 'Requirement')] #[ORM\Entity(repositoryClass: RequirementRepository::class)] #[ORM\EntityListeners([RequirementListener::class])] #[ORM\UniqueConstraint(columns: ['version', 'category', 'name'])] @@ -60,30 +55,22 @@ public function __construct( #[ORM\ManyToOne(targetEntity: MajorVersion::class, inversedBy: 'requirements')] #[ORM\JoinColumn(name: 'version', referencedColumnName: 'version')] private ?MajorVersion $version, - /** - * @OA\Property(example="database") - */ + #[OA\Property(example: 'database')] #[Assert\Choice(callback: [RequirementCategoryEnum::class, 'getAvailableOptions'])] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] - #[Serializer\Groups(['data', 'content', 'patch'])] + #[Groups(['data', 'content', 'patch'])] private string $category, - /** - * @OA\Property(example="mysql") - */ + #[OA\Property(example: 'mysql')] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] - #[Serializer\Groups(['data', 'content', 'patch'])] + #[Groups(['data', 'content', 'patch'])] private string $name, - /** - * @OA\Property(example="5.5") - */ + #[OA\Property(example: 'My Sitepackage')] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, nullable: true)] - #[Serializer\Groups(['data', 'content', 'patch'])] + #[Groups(['data', 'content', 'patch'])] private ?string $min = null, - /** - * @OA\Property(example="5.7") - */ + #[OA\Property(example: '5.7')] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, nullable: true)] - #[Serializer\Groups(['data', 'content', 'patch'])] + #[Groups(['data', 'content', 'patch'])] private ?string $max = null, ) {} diff --git a/src/Entity/Sitepackage.php b/src/Entity/Sitepackage.php index e3b06272..613718a9 100644 --- a/src/Entity/Sitepackage.php +++ b/src/Entity/Sitepackage.php @@ -24,7 +24,6 @@ namespace App\Entity; use App\Entity\Sitepackage\Author; -use JMS\Serializer\Annotation as Serializer; use OpenApi\Attributes as OA; use Symfony\Component\Validator\Constraints as Assert; @@ -35,13 +34,11 @@ class Sitepackage implements \JsonSerializable { #[Assert\NotBlank] #[Assert\Choice(['bootstrap_package', 'fluid_styled_content'])] - #[Serializer\Type('string')] #[OA\Property(type: 'string', example: 'bootstrap_package')] private string $basePackage = 'bootstrap_package'; #[Assert\NotBlank] #[Assert\Choice([10.4, 11.5, 12.4, 13.4])] - #[Serializer\Type('float')] #[OA\Property(type: 'float', example: 13.4)] private float $typo3Version = 13.4; @@ -52,12 +49,10 @@ class Sitepackage implements \JsonSerializable #[Assert\NotBlank(message: 'Please enter a title for your site package')] #[Assert\Length(min: 3)] #[Assert\Regex(pattern: '/^[A-Za-z0-9\x7f-\xff .:&-]+$/', message: 'Only letters, numbers and spaces are allowed')] - #[Serializer\Type('string')] #[OA\Property(type: 'string', example: 'My Sitepackage')] private string $title; #[Assert\Regex(pattern: '/^[A-Za-z0-9\x7f-\xff .,:!?&-]+$/', message: 'Only letters, numbers and spaces are allowed')] - #[Serializer\Type('string')] #[OA\Property(type: 'string', example: 'Project Configuration for Client')] private string $description; @@ -66,12 +61,10 @@ class Sitepackage implements \JsonSerializable private string $extensionKey; #[Assert\Url] - #[Serializer\Type('string')] #[OA\Property(type: 'string', example: 'https://github.com/FriendsOfTYPO3/introduction')] private string $repositoryUrl = ''; #[Assert\Valid] - #[Serializer\Type(Author::class)] private Author $author; public function getTypo3Version(): float diff --git a/src/Entity/Sitepackage/Author.php b/src/Entity/Sitepackage/Author.php index bb59ff33..1760cba5 100644 --- a/src/Entity/Sitepackage/Author.php +++ b/src/Entity/Sitepackage/Author.php @@ -23,7 +23,6 @@ namespace App\Entity\Sitepackage; -use JMS\Serializer\Annotation as Serializer; use OpenApi\Attributes as OA; use Symfony\Component\Validator\Constraints as Assert; @@ -34,26 +33,22 @@ class Author implements \JsonSerializable { #[Assert\NotBlank(message: "Please enter the authors' name.")] #[Assert\Length(min: 3)] - #[Serializer\Type('string')] #[OA\Property(type: 'string', example: 'J. Doe')] private string $name; #[Assert\NotBlank(message: "Please enter the authors' email address.")] #[Assert\Email(message: "The email '{{ value }}' is not a valid email.")] - #[Serializer\Type('string')] #[OA\Property(type: 'string', example: 'info@typo3.com')] private string $email; #[Assert\NotBlank(message: "Please enter the authors' company.")] #[Assert\Length(min: 3)] #[Assert\Regex(pattern: '/^[A-Za-z0-9\x7f-\xff .:&-]+$/', message: 'Only letters, numbers and spaces are allowed')] - #[Serializer\Type('string')] #[OA\Property(type: 'string', example: 'TYPO3')] private string $company; #[Assert\NotBlank(message: "Please enter the authors' homepage URL.")] #[Assert\Url] - #[Serializer\Type('string')] #[OA\Property(type: 'string', example: 'https://typo3.com')] private string $homepage; diff --git a/symfony.lock b/symfony.lock index 605c841e..ddc6ece8 100644 --- a/symfony.lock +++ b/symfony.lock @@ -137,24 +137,6 @@ "guzzlehttp/psr7": { "version": "1.7.0" }, - "jms/metadata": { - "version": "2.4.0" - }, - "jms/serializer": { - "version": "3.10.0" - }, - "jms/serializer-bundle": { - "version": "4.2", - "recipe": { - "repo": "github.com/symfony/recipes-contrib", - "branch": "main", - "version": "4.0", - "ref": "cc04e10cf7171525b50c18b36004edf64cb478be" - }, - "files": [ - "config/packages/jms_serializer.yaml" - ] - }, "justinrainbow/json-schema": { "version": "5.2.11" }, @@ -563,6 +545,18 @@ "config/packages/uid.yaml" ] }, + "symfony/ux-twig-component": { + "version": "2.21", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "2.13", + "ref": "67814b5f9794798b885cec9d3f48631424449a01" + }, + "files": [ + "config/packages/twig_component.yaml" + ] + }, "symfony/validator": { "version": "6.4", "recipe": { diff --git a/tests/Functional/Fixtures/MajorVersionFixtures.php b/tests/Functional/Fixtures/MajorVersionFixtures.php index 9aed3ff8..16cab0d2 100644 --- a/tests/Functional/Fixtures/MajorVersionFixtures.php +++ b/tests/Functional/Fixtures/MajorVersionFixtures.php @@ -25,7 +25,6 @@ use App\Entity\MajorVersion; use Doctrine\Bundle\FixturesBundle\Fixture; -use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Persistence\ObjectManager; final class MajorVersionFixtures extends Fixture @@ -84,65 +83,47 @@ protected function getData(): iterable yield new MajorVersionFixturesData( self::MAJOR_VERSION_SPRINT, new MajorVersion( - 10, - 'TYPO3 10', - '[SUBTITLE]', - '[DESCRIPTION]', - $today, - null, - null, - null, - new ArrayCollection(), - new ArrayCollection(), - null + version: 10, + title: 'TYPO3 10', + subtitle: '[SUBTITLE]', + description: '[DESCRIPTION]', + releaseDate: $today ) ); yield new MajorVersionFixturesData( self::MAJOR_VERSION_LTS, new MajorVersion( - 9, - 'TYPO3 9', - '[SUBTITLE]', - '[DESCRIPTION]', - $today, - null, - $today->modify('+3 years')->modify('-1 day'), - null, - new ArrayCollection(), - new ArrayCollection(), - 9.5 + version: 9, + title: 'TYPO3 9', + subtitle: '[SUBTITLE]', + description: '[DESCRIPTION]', + releaseDate: $today, + maintainedUntil: $today->modify('+3 years')->modify('-1 day'), + lts: 9.5 ) ); yield new MajorVersionFixturesData( self::MAJOR_VERSION_LTS_OLD, new MajorVersion( - 8, - 'TYPO3 8', - '[SUBTITLE]', - '[DESCRIPTION]', - $today->modify('-540 days'), - null, - $today->modify('+540 days')->modify('-1 day'), - null, - new ArrayCollection(), - new ArrayCollection(), - 8.7 + version: 8, + title: 'TYPO3 8', + subtitle: '[SUBTITLE]', + description: '[DESCRIPTION]', + releaseDate: $today->modify('-540 days'), + maintainedUntil: $today->modify('+540 days')->modify('-1 day'), + lts: 8.7 ) ); yield new MajorVersionFixturesData( self::MAJOR_VERSION_ELTS, new MajorVersion( - 7, - 'TYPO3 7', - '[SUBTITLE]', - '[DESCRIPTION]', - $today->modify('-3 years'), - null, - $today->modify('-1 day'), - null, - new ArrayCollection(), - new ArrayCollection(), - 7.6 + version: 7, + title: 'TYPO3 7', + subtitle: '[SUBTITLE]', + description: '[DESCRIPTION]', + releaseDate: $today->modify('-3 years'), + maintainedUntil: $today->modify('-1 day'), + lts: 7.6 ) ); } diff --git a/tests/Unit/Entity/MajorVersionExpected.php b/tests/Unit/Entity/MajorVersionExpected.php index fd571bcd..722d7878 100644 --- a/tests/Unit/Entity/MajorVersionExpected.php +++ b/tests/Unit/Entity/MajorVersionExpected.php @@ -29,10 +29,10 @@ public function __construct( public readonly float $version, public readonly string $title, public readonly \DateTimeImmutable $releaseDate, - public readonly ?\DateTimeImmutable $regularMaintenanceUntil, - public readonly ?\DateTimeImmutable $maintainedUntil, - public readonly ?\DateTimeImmutable $eltsUntil, - public readonly bool $active, - public readonly bool $elts, + public readonly ?\DateTimeImmutable $regularMaintenanceUntil = null, + public readonly ?\DateTimeImmutable $maintainedUntil = null, + public readonly ?\DateTimeImmutable $eltsUntil = null, + public readonly bool $active = false, + public readonly bool $elts = false, ) {} } diff --git a/tests/Unit/Entity/MajorVersionTest.php b/tests/Unit/Entity/MajorVersionTest.php index bee69d04..7b7a5518 100644 --- a/tests/Unit/Entity/MajorVersionTest.php +++ b/tests/Unit/Entity/MajorVersionTest.php @@ -24,7 +24,6 @@ namespace App\Tests\Unit\Entity; use App\Entity\MajorVersion; -use Doctrine\Common\Collections\ArrayCollection; use PHPUnit\Framework\TestCase; class MajorVersionTest extends TestCase @@ -88,131 +87,102 @@ public function entityToJsonTest(MajorVersion $majorVersion, MajorVersionExpecte public function entityTestDataProvider(): \Iterator { $dateTimeToday = new \DateTimeImmutable(); - $collection = new ArrayCollection(); yield 'SPRINT' => [ new MajorVersion( - 10, - 'TYPO3 10', - 'subtitle', - 'description', - $dateTimeToday, - null, - null, - null, - $collection, - $collection, - null + version: 10, + title: 'TYPO3 10', + subtitle: 'subtitle', + description: 'description', + releaseDate: $dateTimeToday ), new MajorVersionExpected( - 10, - 'TYPO3 10', - $dateTimeToday, - null, - null, - null, - true, - false + version: 10, + title: 'TYPO3 10', + releaseDate: $dateTimeToday, + active: true, + elts: false ), ]; yield 'LTS' => [ new MajorVersion( - 9.5, - 'TYPO3 9', - 'subtitle', - 'description', - $dateTimeToday, - null, - $dateTimeToday->modify('+3 years')->modify('-1 day'), - null, - $collection, - $collection, - 9.5 + version: 9.5, + title: 'TYPO3 9', + subtitle: 'subtitle', + description: 'description', + releaseDate: $dateTimeToday, + maintainedUntil: $dateTimeToday->modify('+3 years')->modify('-1 day'), + lts: 9.5 ), new MajorVersionExpected( - 9, - 'TYPO3 9', - $dateTimeToday, - null, - $dateTimeToday->modify('+3 years')->modify('-1 day'), - $dateTimeToday->modify('+6 years')->modify('-1 day'), - true, - false + version: 9, + title: 'TYPO3 9', + releaseDate: $dateTimeToday, + maintainedUntil: $dateTimeToday->modify('+3 years')->modify('-1 day'), + eltsUntil: $dateTimeToday->modify('+6 years')->modify('-1 day'), + active: true, + elts: false ), ]; yield 'ELTS' => [ new MajorVersion( - 7.6, - 'TYPO3 7', - 'subtitle', - 'description', - $dateTimeToday->modify('-3 years'), - null, - $dateTimeToday->modify('-1 day'), - null, - $collection, - $collection, - 7.6 + version: 7.6, + title: 'TYPO3 7', + subtitle: 'subtitle', + description: 'description', + releaseDate: $dateTimeToday->modify('-3 years'), + maintainedUntil: $dateTimeToday->modify('-1 day'), + lts: 7.6 ), new MajorVersionExpected( - 7, - 'TYPO3 7', - $dateTimeToday->modify('-3 years'), - null, - $dateTimeToday->modify('-1 day'), - $dateTimeToday->modify('-1 day')->modify('+3 years'), - false, - true + version: 7, + title: 'TYPO3 7', + releaseDate: $dateTimeToday->modify('-3 years'), + maintainedUntil: $dateTimeToday->modify('-1 day'), + eltsUntil: $dateTimeToday->modify('-1 day')->modify('+3 years'), + active: false, + elts: true ), ]; yield 'ELTS-SET' => [ new MajorVersion( - 6.2, - 'TYPO3 6.2', - 'subtitle', - 'description', - $dateTimeToday->modify('-3 years'), - null, - $dateTimeToday->modify('-1 day'), - $dateTimeToday->modify('-1 day')->modify('+4 years'), - $collection, - $collection, - 6.2 + version: 6.2, + title: 'TYPO3 6.2', + subtitle: 'subtitle', + description: 'description', + releaseDate: $dateTimeToday->modify('-3 years'), + maintainedUntil: $dateTimeToday->modify('-1 day'), + eltsUntil: $dateTimeToday->modify('-1 day')->modify('+4 years'), + lts: 6.2 ), new MajorVersionExpected( - 6.2, - 'TYPO3 6.2', - $dateTimeToday->modify('-3 years'), - null, - $dateTimeToday->modify('-1 day'), - $dateTimeToday->modify('-1 day')->modify('+4 years'), - false, - true + version: 6.2, + title: 'TYPO3 6.2', + releaseDate: $dateTimeToday->modify('-3 years'), + maintainedUntil: $dateTimeToday->modify('-1 day'), + eltsUntil: $dateTimeToday->modify('-1 day')->modify('+4 years'), + active: false, + elts: true ), ]; yield 'OUTDATED' => [ new MajorVersion( - 4.5, - 'TYPO3 4.5', - 'subtitle', - 'description', - $dateTimeToday->modify('-6 years'), - null, - $dateTimeToday->modify('-3 years')->modify('-1 day'), - null, - $collection, - $collection, - 4.5 + version: 4.5, + title: 'TYPO3 4.5', + subtitle: 'subtitle', + description: 'description', + releaseDate: $dateTimeToday->modify('-6 years'), + maintainedUntil: $dateTimeToday->modify('-3 years')->modify('-1 day'), + lts: 4.5 ), new MajorVersionExpected( - 4.5, - 'TYPO3 4.5', - $dateTimeToday->modify('-6 years'), - null, - $dateTimeToday->modify('-3 years')->modify('-1 day'), - $dateTimeToday->modify('-3 years')->modify('-1 day')->modify('+3 years'), - false, - false + version: 4.5, + title: 'TYPO3 4.5', + releaseDate: $dateTimeToday->modify('-6 years'), + maintainedUntil: $dateTimeToday->modify('-3 years')->modify('-1 day'), + eltsUntil: $dateTimeToday->modify('-3 years')->modify('-1 day')->modify('+3 years'), + active: false, + elts: false ), ]; }