mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
fix error when using AccPeriodWorkEvaluationDenormalizer
This commit is contained in:
parent
aae360d6ab
commit
2ea5c4b0c7
@ -61,7 +61,7 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
|
|||||||
* @ORM\SequenceGenerator(sequenceName="chill_person_social_work_eval_doc_id_seq", allocationSize=1, initialValue=1000)
|
* @ORM\SequenceGenerator(sequenceName="chill_person_social_work_eval_doc_id_seq", allocationSize=1, initialValue=1000)
|
||||||
* @Serializer\Groups({"read"})
|
* @Serializer\Groups({"read"})
|
||||||
*/
|
*/
|
||||||
private ?int $id;
|
private ?int $id = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(
|
* @ORM\ManyToOne(
|
||||||
|
@ -11,7 +11,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Chill\PersonBundle\Serializer\Normalizer;
|
namespace Chill\PersonBundle\Serializer\Normalizer;
|
||||||
|
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument;
|
||||||
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
|
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
|
||||||
@ -51,18 +50,16 @@ class AccompanyingPeriodWorkEvaluationDenormalizer implements ContextAwareDenorm
|
|||||||
|
|
||||||
public function denormalize($data, $type, $format = null, array $context = [])
|
public function denormalize($data, $type, $format = null, array $context = [])
|
||||||
{
|
{
|
||||||
$work = $this->denormalizer->denormalize($data, $type, $format, array_merge(
|
$evaluation = $this->denormalizer->denormalize($data, $type, $format, array_merge(
|
||||||
$context,
|
$context,
|
||||||
['skip' => self::class]
|
['skip' => self::class]
|
||||||
));
|
));
|
||||||
dump($work);
|
|
||||||
dump($data);
|
|
||||||
dump($type);
|
|
||||||
//if (in_array('accompanying_period_work:edit', $context['groups'] ?? [], true)) {
|
//if (in_array('accompanying_period_work:edit', $context['groups'] ?? [], true)) {
|
||||||
$this->handleEvaluationCollection($data, $work, $format, $context);
|
$this->handleEvaluationCollection($data, $evaluation, $format, $context);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
return $work;
|
return $evaluation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supportsDenormalization($data, $type, $format = null, array $context = []): bool
|
public function supportsDenormalization($data, $type, $format = null, array $context = []): bool
|
||||||
@ -90,21 +87,23 @@ class AccompanyingPeriodWorkEvaluationDenormalizer implements ContextAwareDenorm
|
|||||||
dump($dataWithoutId);
|
dump($dataWithoutId);
|
||||||
|
|
||||||
dump($evaluation);
|
dump($evaluation);
|
||||||
// partition the separate kept documents and removed one
|
//partition the separate kept documents and removed one
|
||||||
[$kept, $removed] = $evaluation->getDocuments()
|
[$kept, $removed] = $evaluation->getDocuments()
|
||||||
->partition(
|
->partition(
|
||||||
static fn (int $key, AccompanyingPeriodWorkEvaluationDocument $a) => array_key_exists($a->getId(), $dataById)
|
static fn (int $key, AccompanyingPeriodWorkEvaluationDocument $a) => array_key_exists($a->getId(), $dataById)
|
||||||
);
|
);
|
||||||
|
$kept = $evaluation->getDocuments();
|
||||||
|
dump($kept);
|
||||||
|
|
||||||
// remove the document from evaluation
|
// remove the document from evaluation
|
||||||
foreach ($removed as $r) {
|
foreach ($removed as $r) {
|
||||||
$evaluation->removeDocument($r);
|
$evaluation->removeDocument($r);
|
||||||
}
|
}
|
||||||
// handle the documents kept
|
// handle the documents kept
|
||||||
foreach ($kept as $k) {
|
foreach ($kept as $k) {
|
||||||
$this->denormalizer->denormalize(
|
dump($k);// Cannot iterate over $kept which is a PersistentCollection
|
||||||
|
$evaluation->removeDocument($k);
|
||||||
|
dump($evaluation);
|
||||||
|
$document = $this->denormalizer->denormalize(
|
||||||
$dataById[$k->getId()],
|
$dataById[$k->getId()],
|
||||||
AccompanyingPeriodWorkEvaluationDocument::class,
|
AccompanyingPeriodWorkEvaluationDocument::class,
|
||||||
$format,
|
$format,
|
||||||
@ -116,6 +115,8 @@ class AccompanyingPeriodWorkEvaluationDenormalizer implements ContextAwareDenorm
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$evaluation->addDocument($document);
|
||||||
}
|
}
|
||||||
// create new document
|
// create new document
|
||||||
foreach ($dataWithoutId as $newData) {
|
foreach ($dataWithoutId as $newData) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user