mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-10-01 10:59:45 +00:00
Partage d'export enregistré et génération asynchrone des exports
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?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\MainBundle\Service\Regroupement;
|
||||
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
use Chill\MainBundle\Entity\Regroupment;
|
||||
|
||||
class CenterRegroupementResolver
|
||||
{
|
||||
/**
|
||||
* Resolves and returns a unique list of centers by merging those from the provided
|
||||
* groups and the additional centers while eliminating duplicates.
|
||||
*
|
||||
* @param list<Regroupment> $groups
|
||||
* @param list<Center> $centers
|
||||
*
|
||||
* @return list<Center>
|
||||
*/
|
||||
public function resolveCenters(array $groups, array $centers = []): array
|
||||
{
|
||||
$centersByHash = [];
|
||||
|
||||
foreach ($groups as $group) {
|
||||
foreach ($group->getCenters() as $center) {
|
||||
$centersByHash[spl_object_hash($center)] = $center;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($centers as $center) {
|
||||
$centersByHash[spl_object_hash($center)] = $center;
|
||||
}
|
||||
|
||||
return array_values($centersByHash);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user