mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
count linked objects in merge person side panel
This commit is contained in:
@@ -16,6 +16,10 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
use Chill\ActivityBundle\Entity\Activity;
|
||||
use Chill\DocStoreBundle\Entity\PersonDocument;
|
||||
use Chill\EventBundle\Entity\Participation;
|
||||
use Chill\TaskBundle\Entity\SingleTask;
|
||||
|
||||
class PersonDuplicateController extends Controller
|
||||
{
|
||||
@@ -91,6 +95,9 @@ class PersonDuplicateController extends Controller
|
||||
$person1 = $this->_getPerson($person1_id);
|
||||
$person2 = $this->_getPerson($person2_id);
|
||||
|
||||
$person1->counters = $this->_getCounters($person1_id);
|
||||
$person2->counters = $this->_getCounters($person2_id);
|
||||
|
||||
if ($person1 === null) {
|
||||
throw $this->createNotFoundException("Person with id $person1_id not"
|
||||
. " found on this server");
|
||||
@@ -257,4 +264,23 @@ class PersonDuplicateController extends Controller
|
||||
|
||||
return [$person1, $person2];
|
||||
}
|
||||
|
||||
private function _getCounters($id): ?array
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$nb_activity = $em->getRepository(Activity::class)->findBy(['person'=>$id]);
|
||||
$nb_document = $em->getRepository(PersonDocument::class)->findBy(['person'=>$id]);
|
||||
$nb_event = $em->getRepository(Participation::class)->findBy(['person'=>$id]);
|
||||
$nb_task = $em->getRepository(SingleTask::class)->countByParameters(['person'=>$id]);
|
||||
$person = $em->getRepository(Person::class)->findOneBy(['id'=>$id]);
|
||||
|
||||
return [
|
||||
'nb_activity' => count($nb_activity),
|
||||
'nb_document' => count($nb_document),
|
||||
'nb_event' => count($nb_event),
|
||||
'nb_task' => $nb_task,
|
||||
'nb_addresses' => count($person->getAddresses())
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user