public function setCampaignSegment(DeliveranceCampaignSegment $campaign_segment = null)
 {
     $this->campaign_segment = $campaign_segment;
     if ($campaign_segment !== null) {
         $this->setSegmentOptions($this->campaign_segment->getSegmentOptions());
     }
 }
 protected function updateSegment(DeliveranceList $list, DeliveranceCampaignSegment $segment)
 {
     if ($list->isAvailable()) {
         $this->debug(sprintf(Deliverance::_('Updating ‘%s’... '), $segment->title));
         try {
             $size = $list->getSegmentSize($segment->getSegmentOptions());
             $segment->cached_segment_size = $size;
             $segment->save();
             $locale = SwatI18NLocale::get();
             $this->debug(sprintf(Deliverance::_('found %s subscribers.') . "\n", $locale->formatNumber($size)));
         } catch (DeliveranceApiConnectionException $e) {
             // ignore these exceptions. segment sizes will be updated next
             // time around.
             $this->debug(sprintf(Deliverance::_('list unavailable. Segment ‘%s’ was not updated.') . "\n", $segment->title));
         } catch (Exception $e) {
             $e = new DeliveranceException($e);
             $e->processAndContinue();
             $this->debug(sprintf(Deliverance::_('Update error. Segment ‘%s’ was not updated.') . "\n", $segment->title));
         }
     } else {
         $this->debug(sprintf(Deliverance::_('Mailing list unavailable. Segment ‘%s’ was not updated.') . "\n", $segment->title));
     }
 }