Feature: show comment in #docgen generation for accompanying periods

This commit is contained in:
Julien Fastré 2022-07-11 19:56:59 +02:00
parent b3da9611ce
commit 5f6c11bde9
3 changed files with 10 additions and 4 deletions

View File

@ -40,7 +40,7 @@ class Comment implements TrackCreationInterface, TrackUpdateInterface
/**
* @ORM\Column(type="text")
* @Groups({"read", "write"})
* @Groups({"read", "write", "docgen:read"})
* @Assert\NotBlank
* @Assert\NotNull
*/
@ -48,14 +48,14 @@ class Comment implements TrackCreationInterface, TrackUpdateInterface
/**
* @ORM\Column(type="datetime")
* @Groups({"read"})
* @Groups({"read", "docgen:read"})
*/
private $createdAt;
/**
* @ORM\ManyToOne(targetEntity=User::class)
* @ORM\JoinColumn(nullable=false)
* @Groups({"read"})
* @Groups({"read", "docgen:read"})
*/
private $creator;
@ -63,7 +63,7 @@ class Comment implements TrackCreationInterface, TrackUpdateInterface
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({"read"})
* @Groups({"read", "docgen:read"})
*/
private $id;

View File

@ -71,6 +71,7 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf
'location' => Address::class,
'locationPerson' => Person::class,
'administrativeLocation' => Location::class,
'pinnedComment' => AccompanyingPeriod\Comment::class,
];
private ClosingMotiveRender $closingMotiveRender;
@ -164,6 +165,8 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf
'location' => $this->normalizer->normalize($period->getLocation(), $format, $addressContext),
'administrativeLocation' => $this->normalizer->normalize($period->getAdministrativeLocation(), $format, $administrativeLocationContext),
'works' => $this->normalizer->normalize($period->getWorks(), $format, $workContext),
'comments' => $this->normalizer->normalize($period->getComments(), $format, array_merge($context, ['docgen:expects' => AccompanyingPeriod\Comment::class])),
'pinnedComment' => $this->normalizer->normalize($period->getPinnedComment(), $format, array_merge($context, ['docgen:expects' => AccompanyingPeriod\Comment::class])),
];
}
@ -183,6 +186,7 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf
'hasLocationPerson' => false,
'hasAdministrativeLocation' => false,
'works' => [],
'comments' => [],
]
);
}

View File

@ -68,6 +68,8 @@ final class AccompanyingPeriodDocGenNormalizerTest extends KernelTestCase
'closingMotive' => '@ignored',
'confidential' => true,
'confidentialText' => 'confidentiel',
'comments' => '@ignored',
'pinnedComment' => '@ignored',
'createdAt' => '@ignored',
'createdBy' => '@ignored',
'emergency' => true,