protected function getCampaignListAction()
    {
        $output = [];
        /** @var CampaignRepository */
        $campaignRepository = $this->get('mautic.campaign.model.campaign')->getRepository();
        $campaigns          = $campaignRepository->getEntities();
        foreach ($campaigns as $campaign) {
            $id                                  = $campaign->getId();
            $published                           = $campaign->isPublished();
            $name                                = $campaign->getName();
            $category                            = $campaign->getCategory();
            $category                            = $category ? $category->getName() : '';
            $output[$name.'_'.$category.'_'.$id] = [
                'category'  => $category,
                'published' => $published,
                'name'      => $name,
                'title'     => htmlspecialchars_decode($name.($category ? '  ('.$category.')' : '').(!$published ? '  (unpublished)' : '')),
                'value'     => $id,
            ];
        }
        $output['   '] = [
            'value' => 0,
            'title' => count($output) ? '-- Select a Campaign --' : '-- Please create a Campaign --',
        ];
        // Sort by name and category if not already, then drop the keys.
        ksort($output);

        return $this->sendJsonResponse(
            [
                'array' => array_values($output),
            ]
        );
    }
protected function getCampaignListAction()
    {
        $output = [];
        /** @var CampaignRepository */
        $campaignRepository = $this->get('mautic.campaign.model.campaign')->getRepository();
        $campaigns          = $campaignRepository->getEntities();
        foreach ($campaigns as $campaign) {
            $id                                  = $campaign->getId();
            $published                           = $campaign->isPublished();
            $name                                = $campaign->getName();
            $category                            = $campaign->getCategory();
            $category                            = $category ? $category->getName() : '';
            $output[$name.'_'.$category.'_'.$id] = [
                'category'  => $category,
                'published' => $published,
                'name'      => $name,
                'title'     => htmlspecialchars_decode($name.($category ? '  ('.$category.')' : '').(!$published ? '  (unpublished)' : '')),
                'value'     => $id,
            ];
        }
        $output['   '] = [
            'value' => 0,
            'title' => count($output) ? '-- Select a Campaign --' : '-- Please create a Campaign --',
        ];
        // Sort by name and category if not already, then drop the keys.
        ksort($output);

        return $this->sendJsonResponse(
            [
                'array' => array_values($output),
            ]
        );
    }
protected function getCampaignListAction ( ) { $ output = [ ] ; /** @var CampaignRepository */ $ campaignRepository = $ this -> get ( 'mautic.campaign.model.campaign' ) -> getRepository ( ) ; $ campaigns = $ campaignRepository -> getEntities ( ) ; foreach ( $ campaigns as $ campaign ) { $ id = $ campaign -> getId ( ) ; $ published = $ campaign -> isPublished ( ) ; $ name = $ campaign -> getName ( ) ; $ category = $ campaign -> getCategory ( ) ; $ category = $ category ? $ category -> getName ( ) : '' ; $ output [ $ name . '_' . $ category . '_' . $ id ] = [ 'category' => $ category , 'published' => $ published , 'name' => $ name , 'title' => htmlspecialchars_decode ( $ name . ( $ category ? '  (' . $ category . ')' : '' ) . ( ! $ published ? '  (unpublished)' : '' ) ) , 'value' => $ id , ] ; } $ output [ '   ' ] = [ 'value' => 0 , 'title' => count ( $ output ) ? '-- Select a Campaign --' : '-- Please create a Campaign --' , ] ; // Sort by name and category if not already, then drop the keys. ksort ( $ output ) ; return $ this -> sendJsonResponse ( [ 'array' => array_values ( $ output ) , ] ) ; }
Retrieve a list of campaigns for use in drop-downs.

@return \Symfony\Component\HttpFoundation\JsonResponse

@throws \Exception
Retrieve a list of campaigns for use in drop - downs .