get('lead_batch', []); $contactIds = empty($params['ids']) ? [] : json_decode($params['ids']); if ($contactIds && is_array($contactIds)) { $segmentsToAdd = $params['add'] ?? []; $segmentsToRemove = $params['remove'] ?? []; if ($segmentsToAdd) { $this->segmentActionModel->addContacts($contactIds, $segmentsToAdd); } if ($segmentsToRemove) { $this->segmentActionModel->removeContacts($contactIds, $segmentsToRemove); } $this->addFlashMessage('mautic.lead.batch_leads_affected', [ '%count%' => count($contactIds), ]); } else { $this->addFlashMessage('mautic.core.error.ids.missing'); } return new JsonResponse([ 'closeModal' => true, 'flashes' => $this->getFlashContent(), ]); } /** * View for batch action. */ public function indexAction(): \Symfony\Component\HttpFoundation\Response { $route = $this->generateUrl('mautic_segment_batch_contact_set'); $lists = $this->segmentModel->getUserLists(); $items = []; foreach ($lists as $list) { $items[$list['name']] = $list['id']; } return $this->delegateView( [ 'viewParameters' => [ 'form' => $this->createForm( BatchType::class, [], [ 'items' => $items, 'action' => $route, ] )->createView(), ], 'contentTemplate' => '@MauticLead/Batch/form.html.twig', 'passthroughVars' => [ 'activeLink' => '#mautic_contact_index', 'mauticContent' => 'leadBatch', 'route' => $route, ], ] ); } }