protected function preSerializeEntity(&$entity, $action = 'view')
    {
        // deconstruct the campaign_settings blob and merge campaign entities in.
        $list             = [];
        $campaignSettings = json_decode($entity->getCampaignSettings(), true);
        $campaignModel    = $this->container->get('mautic.campaign.model.campaign');
        if (!empty($campaignSettings)) {
            foreach ($campaignSettings as $campaignSetting) {
                if (!empty($campaignSetting)) {
                    foreach ($campaignSetting as $setting) {
                        // get campaign name or other fields to merge with this data.
                        $campaign                       = $campaignModel->getEntity($setting['campaignId']);
                        if ($campaign && $campaign instanceof Campaign) {
                            $campaignName                   = $campaign->getName();
                            $campaignDescription            = $campaign->getDescription();
                            $setting['campaignName']        = $campaignName;
                            $setting['campaignDescription'] = $campaignDescription;
                            $list[$setting['campaignId']]   = $setting;
                            unset($campaign, $campaignName, $campaignDescription);
                        }
                    }
                }
            }
            $entity->setCampaignList($list);
        }
    }
protected function preSerializeEntity(&$entity, $action = 'view')
    {
        // deconstruct the campaign_settings blob and merge campaign entities in.
        $list             = [];
        $campaignSettings = json_decode($entity->getCampaignSettings(), true);
        $campaignModel    = $this->container->get('mautic.campaign.model.campaign');
        if (!empty($campaignSettings)) {
            foreach ($campaignSettings as $campaignSetting) {
                if (!empty($campaignSetting)) {
                    foreach ($campaignSetting as $setting) {
                        // get campaign name or other fields to merge with this data.
                        $campaign                       = $campaignModel->getEntity($setting['campaignId']);
                        if ($campaign && $campaign instanceof Campaign) {
                            $campaignName                   = $campaign->getName();
                            $campaignDescription            = $campaign->getDescription();
                            $setting['campaignName']        = $campaignName;
                            $setting['campaignDescription'] = $campaignDescription;
                            $list[$setting['campaignId']]   = $setting;
                            unset($campaign, $campaignName, $campaignDescription);
                        }
                    }
                }
            }
            $entity->setCampaignList($list);
        }
    }
protected function preSerializeEntity ( & $ entity , $ action = 'view' ) { // deconstruct the campaign_settings blob and merge campaign entities in. $ list = [ ] ; $ campaignSettings = json_decode ( $ entity -> getCampaignSettings ( ) , true ) ; $ campaignModel = $ this -> container -> get ( 'mautic.campaign.model.campaign' ) ; if ( ! empty ( $ campaignSettings ) ) { foreach ( $ campaignSettings as $ campaignSetting ) { if ( ! empty ( $ campaignSetting ) ) { foreach ( $ campaignSetting as $ setting ) { // get campaign name or other fields to merge with this data. $ campaign = $ campaignModel -> getEntity ( $ setting [ 'campaignId' ] ) ; if ( $ campaign && $ campaign instanceof Campaign ) { $ campaignName = $ campaign -> getName ( ) ; $ campaignDescription = $ campaign -> getDescription ( ) ; $ setting [ 'campaignName' ] = $ campaignName ; $ setting [ 'campaignDescription' ] = $ campaignDescription ; $ list [ $ setting [ 'campaignId' ] ] = $ setting ; unset ( $ campaign , $ campaignName , $ campaignDescription ) ; } } } } $ entity -> setCampaignList ( $ list ) ; } }
Opportunity to analyze and do whatever to an entity before going through serializer.

@param        $entity
@param string $action

@return mixed
Opportunity to analyze and do whatever to an entity before going through serializer .