コード例 #1
0
 /**
  * Handle
  *
  * @param Subscription $subscription
  */
 public function handle(Subscription $subscription)
 {
     // Init variables
     $mergeFields = array();
     $interests = array();
     try {
         // We must overwrite existing interests
         if ($this->modulesSettings->get('Mailmotor', 'overwrite_interests', true)) {
             $possibleInterests = $this->subscriber->getInterests();
             // Loop interests
             foreach ($possibleInterests as $categoryId => $categoryInterest) {
                 foreach ($categoryInterest['children'] as $categoryChildId => $categoryChildTitle) {
                     // Add interest
                     $interests[$categoryChildId] = in_array($categoryChildId, $subscription->interests);
                 }
             }
         } elseif (!empty($subscription->interests)) {
             // Loop checked interests
             foreach ($subscription->interests as $checkedInterestId) {
                 // Add interest
                 $interests[$checkedInterestId] = true;
             }
         }
         // Fallback for when no mail-engine is chosen in the Backend
     } catch (NotImplementedException $e) {
     }
     // Subscribing the user, will dispatch an event
     $this->subscriber->subscribe($subscription->email, $subscription->language, $mergeFields, $interests);
 }
コード例 #2
0
ファイル: SubscribeType.php プロジェクト: forkcms/forkcms
 /**
  * @return array
  */
 public function getInterests()
 {
     $interests = array();
     try {
         $mailMotorInterests = $this->subscriber->getInterests();
         // Has interests
         if (!empty($mailMotorInterests)) {
             // Loop interests
             foreach ($mailMotorInterests as $categoryId => $categoryInterest) {
                 foreach ($categoryInterest['children'] as $categoryChildId => $categoryChildTitle) {
                     // Add interest value for checkbox
                     $interests[$categoryChildId] = $categoryChildTitle;
                 }
             }
         }
         // Fallback for when no mail-engine is chosen in the Backend
     } catch (NotImplementedException $e) {
     }
     return $interests;
 }