mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
normalization for docgen:read: add groups and so on (wip)
This commit is contained in:
@@ -90,11 +90,6 @@ final class DocGeneratorTemplateController extends AbstractController
|
||||
int $entityId,
|
||||
Request $request
|
||||
): Response {
|
||||
$entity = $this->getDoctrine()->getRepository($entityClassName)->find($entityId);
|
||||
|
||||
if (null === $entity) {
|
||||
throw new NotFoundHttpException("Entity with classname {$entityClassName} and id {$entityId} is not found");
|
||||
}
|
||||
|
||||
try {
|
||||
$context = $this->contextManager->getContextByDocGeneratorTemplate($template);
|
||||
@@ -102,6 +97,12 @@ final class DocGeneratorTemplateController extends AbstractController
|
||||
throw new NotFoundHttpException($e->getMessage(), $e);
|
||||
}
|
||||
|
||||
$entity = $this->getDoctrine()->getRepository($context->getEntityClass())->find($entityId);
|
||||
|
||||
if (null === $entity) {
|
||||
throw new NotFoundHttpException("Entity with classname {$entityClassName} and id {$entityId} is not found");
|
||||
}
|
||||
|
||||
$contextGenerationData = [];
|
||||
|
||||
if ($context instanceof DocGeneratorContextWithPublicFormInterface
|
||||
|
@@ -210,7 +210,17 @@ class DocGenObjectNormalizer implements NormalizerAwareInterface, NormalizerInte
|
||||
$value = $this->propertyAccess->getValue($object, $attribute->getName());
|
||||
$key = $attribute->getSerializedName() ?? $attribute->getName();
|
||||
|
||||
if (is_object($value)) {
|
||||
if (is_iterable($value)) {
|
||||
$arr = [];
|
||||
foreach ($value as $k => $v) {
|
||||
$arr[$k] =
|
||||
$this->normalizer->normalize($v, $format, array_merge(
|
||||
$context,
|
||||
$attribute->getNormalizationContextForGroups($expectedGroups)
|
||||
));
|
||||
}
|
||||
$data[$key] = $arr;
|
||||
} elseif (is_object($value)) {
|
||||
$data[$key] =
|
||||
$this->normalizer->normalize($value, $format, array_merge(
|
||||
$context,
|
||||
|
Reference in New Issue
Block a user