You are here

public function MailchimpSignup::__construct in Mailchimp 7.4

Same name and namespace in other branches
  1. 7.5 modules/mailchimp_signup/includes/mailchimp_signup.entity.inc \MailchimpSignup::__construct()
  2. 7.3 modules/mailchimp_signup/includes/mailchimp_signup.entity.inc \MailchimpSignup::__construct()

Override parent constructor to set the entity type.

Overrides Entity::__construct

File

modules/mailchimp_signup/includes/mailchimp_signup.entity.inc, line 20
Mailchimp Signup entity class

Class

MailchimpSignup
@file Mailchimp Signup entity class

Code

public function __construct(array $values = array()) {

  // The Features module calls the entity controller with all values cast to
  // an array. The mergefields and its settings are returned by the Mailchimp
  // API as objects. When constructing the entity from the Features import,
  // cast the mergefields back to objects for a consistent data model.
  if (!empty($values['settings']['mergefields'])) {
    foreach ($values['settings']['mergefields'] as $tag => $mergefield) {
      if (is_array($mergefield)) {
        if (isset($mergefield['options']) && is_array($mergefield['options'])) {
          $mergefield['options'] = (object) $mergefield['options'];
        }
        $values['settings']['mergefields'][$tag] = (object) $mergefield;
      }
    }
  }
  parent::__construct($values, 'mailchimp_signup');
}