get('lead_batch'); $ids = empty($params['ids']) ? [] : json_decode($params['ids']); if ($ids && is_array($ids)) { $categoriesToAdd = $params['add'] ?? []; $categoriesToRemove = $params['remove'] ?? []; $contactIds = json_decode($params['ids']); $this->actionModel->addContactsToCategories($contactIds, $categoriesToAdd); $this->actionModel->removeContactsFromCategories($contactIds, $categoriesToRemove); $this->addFlashMessage('mautic.lead.batch_leads_affected', [ '%count%' => count($ids), ]); } else { $this->addFlashMessage('mautic.core.error.ids.missing'); } return new JsonResponse([ 'closeModal' => true, 'flashes' => $this->getFlashContent(), ]); } /** * View the modal form for adding contacts into categories in batches. */ public function indexAction(): \Symfony\Component\HttpFoundation\Response { $route = $this->generateUrl('mautic_category_batch_contact_set'); $rows = $this->categoryModel->getLookupResults('global', '', 300); $items = []; foreach ($rows as $category) { $items[$category['title']] = $category['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, ], ] ); } }