mirror of
				https://gitlab.com/Chill-Projet/chill-bundles.git
				synced 2025-10-31 01:08:26 +00:00 
			
		
		
		
	Merge branch 'master' into upgrade-php82
This commit is contained in:
		| @@ -18,8 +18,10 @@ use Chill\DocGeneratorBundle\Service\Context\BaseContextData; | ||||
| use Chill\DocStoreBundle\Entity\StoredObject; | ||||
| use Chill\MainBundle\Templating\TranslatableStringHelperInterface; | ||||
| use Chill\PersonBundle\Entity\Person; | ||||
| use Chill\PersonBundle\Repository\PersonRepository; | ||||
| use Chill\PersonBundle\Templating\Entity\PersonRender; | ||||
| use Chill\ThirdPartyBundle\Entity\ThirdParty; | ||||
| use Chill\ThirdPartyBundle\Repository\ThirdPartyRepository; | ||||
| use Chill\ThirdPartyBundle\Templating\Entity\ThirdPartyRender; | ||||
| use Doctrine\ORM\EntityManagerInterface; | ||||
| use Symfony\Bridge\Doctrine\Form\Type\EntityType; | ||||
| @@ -41,6 +43,10 @@ final class CalendarContext implements CalendarContextInterface | ||||
|  | ||||
|     private PersonRender $personRender; | ||||
|  | ||||
|     private PersonRepository $personRepository; | ||||
|  | ||||
|     private ThirdPartyRepository $thirdPartyRepository; | ||||
|  | ||||
|     private ThirdPartyRender $thirdPartyRender; | ||||
|  | ||||
|     private TranslatableStringHelperInterface $translatableStringHelper; | ||||
| @@ -50,14 +56,18 @@ final class CalendarContext implements CalendarContextInterface | ||||
|         EntityManagerInterface $entityManager, | ||||
|         NormalizerInterface $normalizer, | ||||
|         PersonRender $personRender, | ||||
|         PersonRepository $personRepository, | ||||
|         ThirdPartyRender $thirdPartyRender, | ||||
|         ThirdPartyRepository $thirdPartyRepository, | ||||
|         TranslatableStringHelperInterface $translatableStringHelper | ||||
|     ) { | ||||
|         $this->baseContextData = $baseContextData; | ||||
|         $this->entityManager = $entityManager; | ||||
|         $this->normalizer = $normalizer; | ||||
|         $this->personRender = $personRender; | ||||
|         $this->personRepository = $personRepository; | ||||
|         $this->thirdPartyRender = $thirdPartyRender; | ||||
|         $this->thirdPartyRepository = $thirdPartyRepository; | ||||
|         $this->translatableStringHelper = $translatableStringHelper; | ||||
|     } | ||||
|  | ||||
| @@ -229,12 +239,36 @@ final class CalendarContext implements CalendarContextInterface | ||||
|  | ||||
|     public function contextGenerationDataNormalize(DocGeneratorTemplate $template, $entity, array $data): array | ||||
|     { | ||||
|         // TODO: Implement publicFormTransform() method. | ||||
|         $normalized['title'] = $data['title'] ?? ''; | ||||
|  | ||||
|         foreach (['mainPerson', 'thirdParty'] as $k) { | ||||
|             if (isset($data[$k])) { | ||||
|                 $normalized[$k] = $data[$k]->getId(); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return $normalized; | ||||
|     } | ||||
|  | ||||
|     public function contextGenerationDataDenormalize(DocGeneratorTemplate $template, $entity, array $data): array | ||||
|     { | ||||
|         // TODO: Implement publicFormReverseTransform() method. | ||||
|         $denormalized['title'] = $data['title']; | ||||
|  | ||||
|         if (null !== ($data['mainPerson'] ?? null)) { | ||||
|             if (null === $person = $this->personRepository->find($data['mainPerson'])) { | ||||
|                 throw new \RuntimeException('person not found'); | ||||
|             } | ||||
|             $denormalized['mainPerson'] = $person; | ||||
|         } | ||||
|  | ||||
|         if (null !== ($data['thirdParty'] ?? null)) { | ||||
|             if (null === $thirdParty = $this->thirdPartyRepository->find($data['thirdParty'])) { | ||||
|                 throw new \RuntimeException('third party not found'); | ||||
|             } | ||||
|             $denormalized['thirdParty'] = $thirdParty; | ||||
|         } | ||||
|  | ||||
|         return $denormalized; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|   | ||||
		Reference in New Issue
	
	Block a user