mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-29 11:03:50 +00:00
Merge remote-tracking branch 'origin/master' into rector/rules-up-to-php80
Conflicts: src/Bundle/ChillActivityBundle/Controller/ActivityController.php src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php src/Bundle/ChillActivityBundle/Menu/PersonMenuBuilder.php src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php src/Bundle/ChillCalendarBundle/Command/MapAndSubscribeUserCalendarCommand.php src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSGraphUserRepository.php src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php src/Bundle/ChillDocStoreBundle/Repository/PersonDocumentACLAwareRepository.php src/Bundle/ChillEventBundle/Search/EventSearch.php src/Bundle/ChillMainBundle/Controller/ExportController.php src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php src/Bundle/ChillMainBundle/Cron/CronManager.php src/Bundle/ChillMainBundle/Entity/CronJobExecution.php src/Bundle/ChillMainBundle/Export/ExportManager.php src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php src/Bundle/ChillMainBundle/Repository/NotificationRepository.php src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperFactory.php src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php src/Bundle/ChillPersonBundle/Controller/SocialWorkSocialActionApiController.php src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/AgeAggregator.php src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php
This commit is contained in:
@@ -13,6 +13,7 @@ namespace Chill\DocGeneratorBundle\Serializer\Normalizer;
|
||||
|
||||
use ArrayObject;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Collections\ReadableCollection;
|
||||
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
|
||||
@@ -51,7 +52,9 @@ class CollectionDocGenNormalizer implements ContextAwareNormalizerInterface, Nor
|
||||
return false;
|
||||
}
|
||||
|
||||
return $data instanceof Collection
|
||||
|| (null === $data && Collection::class === ($context['docgen:expects'] ?? null));
|
||||
return $data instanceof ReadableCollection
|
||||
|| (null === $data && Collection::class === ($context['docgen:expects'] ?? null))
|
||||
|| (null === $data && ReadableCollection::class === ($context['docgen:expects'] ?? null))
|
||||
;
|
||||
}
|
||||
}
|
||||
|
@@ -13,6 +13,7 @@ namespace Chill\DocGeneratorBundle\Serializer\Normalizer;
|
||||
|
||||
use Chill\DocGeneratorBundle\Serializer\Helper\NormalizeNullValueHelper;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use Doctrine\Common\Collections\ReadableCollection;
|
||||
use ReflectionClass;
|
||||
use RuntimeException;
|
||||
use Symfony\Component\PropertyAccess\PropertyAccess;
|
||||
@@ -262,6 +263,14 @@ class DocGenObjectNormalizer implements NormalizerAwareInterface, NormalizerInte
|
||||
if ($isTranslatable) {
|
||||
$data[$key] = $this->translatableStringHelper
|
||||
->localize($value);
|
||||
} elseif ($value instanceof ReadableCollection) {
|
||||
// when normalizing collection, we should not preserve keys (to ensure that the result is a list)
|
||||
// this is why we make call to the normalizer again to use the CollectionDocGenNormalizer
|
||||
$data[$key] =
|
||||
$this->normalizer->normalize($value, $format, array_merge(
|
||||
$objectContext,
|
||||
$attribute->getNormalizationContextForGroups($expectedGroups)
|
||||
));
|
||||
} elseif (is_iterable($value)) {
|
||||
$arr = [];
|
||||
|
||||
|
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\DocGeneratorBundle\tests\Serializer\Normalizer;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Criteria;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
class CollectionDocGenNormalizerTest extends KernelTestCase
|
||||
{
|
||||
private NormalizerInterface $normalizer;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
self::bootKernel();
|
||||
$this->normalizer = self::$container->get(NormalizerInterface::class);
|
||||
}
|
||||
|
||||
public function testNormalizeFilteredArray(): void
|
||||
{
|
||||
$coll = new ArrayCollection([
|
||||
(object) ['v' => 'foo'],
|
||||
(object) ['v' => 'bar'],
|
||||
(object) ['v' => 'baz'],
|
||||
]);
|
||||
|
||||
//filter to get non continuous indexes
|
||||
$criteria = new Criteria();
|
||||
$criteria->where(Criteria::expr()->neq('v', 'bar'));
|
||||
|
||||
$filtered = $coll->matching($criteria);
|
||||
$normalized = $this->normalizer->normalize($filtered, 'docgen', []);
|
||||
|
||||
self::assertIsArray($normalized);
|
||||
self::assertArrayHasKey(0, $normalized);
|
||||
self::assertArrayHasKey(1, $normalized);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user