Skip to content

Commit

Permalink
[TASK] Replace jms/serializer with symfony/serializer (#472)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminkott authored Nov 28, 2024
1 parent d7334f1 commit 38e981b
Show file tree
Hide file tree
Showing 24 changed files with 452 additions and 766 deletions.
2 changes: 0 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
371 changes: 103 additions & 268 deletions composer.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -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],
];
33 changes: 0 additions & 33 deletions config/packages/jms_serializer.yaml

This file was deleted.

4 changes: 4 additions & 0 deletions config/packages/serializer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# config/packages/serializer.yaml
framework:
serializer:
name_converter: 'serializer.name_converter.camel_case_to_snake_case'
5 changes: 5 additions & 0 deletions config/packages/twig_component.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
twig_component:
anonymous_template_directory: 'components/'
defaults:
# Namespace & directory for components
App\Twig\Components\: 'components/'
2 changes: 1 addition & 1 deletion src/Controller/Api/AbstractController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 13 additions & 5 deletions src/Controller/Api/MajorVersion/ReleasesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'])]
Expand Down Expand Up @@ -73,7 +73,9 @@ public function getReleasesByMajorVersion(string $version): JsonResponse
return $this->getSerializer()->serialize(
$majorVersion->getReleases(),
'json',
SerializationContext::create()->setGroups(['data'])
[
AbstractNormalizer::GROUPS => ['data'],
]
);
});

Expand Down Expand Up @@ -113,7 +115,9 @@ public function getLatestReleaseByMajorVersion(string $version): JsonResponse
return $this->getSerializer()->serialize(
$majorVersion->getLatestRelease(),
'json',
SerializationContext::create()->setGroups(['data'])
[
AbstractNormalizer::GROUPS => ['data'],
]
);
});

Expand Down Expand Up @@ -160,7 +164,9 @@ public function getLatestSecurityReleaseByMajorVersion(string $version): JsonRes
$json = $this->getSerializer()->serialize(
$release,
'json',
SerializationContext::create()->setGroups(['data'])
[
AbstractNormalizer::GROUPS => ['data'],
]
);
}

Expand Down Expand Up @@ -204,7 +210,9 @@ public function getLatestReleaseContentByMajorVersion(string $version): JsonResp
return $this->getSerializer()->serialize(
$majorVersion->getLatestRelease(),
'json',
SerializationContext::create()->setGroups(['content'])
[
AbstractNormalizer::GROUPS => ['content'],
]
);
});

Expand Down
10 changes: 7 additions & 3 deletions src/Controller/Api/MajorVersion/RequirementsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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(
Expand Down Expand Up @@ -86,7 +86,9 @@ public function getRequirementsByMajorVersion(string $version): JsonResponse
return $this->getSerializer()->serialize(
$requirements,
'json',
SerializationContext::create()->setGroups(['data'])
[
AbstractNormalizer::GROUPS => ['data'],
]
);
});

Expand Down Expand Up @@ -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);
}
Expand Down
14 changes: 10 additions & 4 deletions src/Controller/Api/MajorVersionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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'])]
Expand Down Expand Up @@ -68,7 +68,9 @@ public function getMajorReleases(): JsonResponse
return $this->getSerializer()->serialize(
$majors,
'json',
SerializationContext::create()->setGroups(['content'])
[
AbstractNormalizer::GROUPS => ['content'],
]
);
});

Expand Down Expand Up @@ -112,7 +114,9 @@ public function getMajorRelease(string $version): JsonResponse
return $this->getSerializer()->serialize(
$majorVersion,
'json',
SerializationContext::create()->setGroups(['content'])
[
AbstractNormalizer::GROUPS => ['content'],
]
);
});

Expand Down Expand Up @@ -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);
}
Expand Down
14 changes: 10 additions & 4 deletions src/Controller/Api/ReleaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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'])]
Expand Down Expand Up @@ -92,7 +92,9 @@ public function getRelease(?string $version): JsonResponse
return $this->getSerializer()->serialize(
$releases,
'json',
SerializationContext::create()->setGroups(['data'])
[
AbstractNormalizer::GROUPS => ['data'],
]
);
});

Expand Down Expand Up @@ -272,7 +274,9 @@ public function getContentForVersion(string $version): JsonResponse
return $this->getSerializer()->serialize(
$release,
'json',
SerializationContext::create()->setGroups(['content'])
[
AbstractNormalizer::GROUPS => ['content'],
]
);
});

Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Api/SitepackageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down
Loading

0 comments on commit 38e981b

Please sign in to comment.