mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Update type handling in entity normalization methods
Extended support for `string` types in `normalizeDoctrineEntity` and `denormalizeDoctrineEntity` methods. This ensures compatibility with a broader range of identifier formats and improves flexibility in entity processing.
This commit is contained in:
parent
e0f94ae900
commit
8c5abbff74
@ -19,7 +19,7 @@ trait ExportDataNormalizerTrait
|
|||||||
/**
|
/**
|
||||||
* @param object|list<object> $entity
|
* @param object|list<object> $entity
|
||||||
*/
|
*/
|
||||||
public function normalizeDoctrineEntity(object|array|null $entity): array|int
|
public function normalizeDoctrineEntity(object|array|null $entity): array|int|string
|
||||||
{
|
{
|
||||||
if (is_array($entity)) {
|
if (is_array($entity)) {
|
||||||
return array_values(array_filter(array_map(static fn (object $entity) => $entity->getId(), $entity), fn ($value) => null !== $value));
|
return array_values(array_filter(array_map(static fn (object $entity) => $entity->getId(), $entity), fn ($value) => null !== $value));
|
||||||
@ -31,7 +31,7 @@ trait ExportDataNormalizerTrait
|
|||||||
return $entity?->getId();
|
return $entity?->getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function denormalizeDoctrineEntity(array|int $id, ObjectRepository $repository): object|array
|
public function denormalizeDoctrineEntity(array|int|string $id, ObjectRepository $repository): object|array
|
||||||
{
|
{
|
||||||
if (is_array($id)) {
|
if (is_array($id)) {
|
||||||
return $repository->findBy(['id' => $id]);
|
return $repository->findBy(['id' => $id]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user