class MailChimpCampaign in Mailchimp 7.4
Same name and namespace in other branches
- 7.5 modules/mailchimp_campaign/includes/mailchimp_campaign.entity.inc \MailChimpCampaign
- 7.2 modules/mailchimp_campaign/mailchimp_campaign.entity.inc \MailChimpCampaign
- 7.3 modules/mailchimp_campaign/includes/mailchimp_campaign.entity.inc \MailChimpCampaign
@file MailChimpCampaign entity class.
Hierarchy
- class \Entity implements EntityInterface
- class \MailChimpCampaign
Expanded class hierarchy of MailChimpCampaign
1 string reference to 'MailChimpCampaign'
- mailchimp_campaign_entity_info in modules/
mailchimp_campaign/ mailchimp_campaign.module - Implements hook_entity_info().
File
- modules/
mailchimp_campaign/ includes/ mailchimp_campaign.entity.inc, line 8 - MailChimpCampaign entity class.
View source
class MailChimpCampaign extends Entity {
public $mc_campaign_id, $template, $created, $updated, $mc_data, $list, $mc_template;
/**
* Overrides parent::__construct().
*/
public function __construct(array $values = array(), $entity_type = 'mailchimp_campaign') {
parent::__construct($values, $entity_type);
}
/**
* Assemble html representation of the Campaign content.
*/
public function buildContent($view_mode = 'full', $langcode = NULL) {
$build = parent::buildContent($view_mode, $langcode);
// Prepare rendered content:
$content = mailchimp_campaign_render_template($this->template);
$rendered = '';
foreach ($content as $key => $section) {
$rendered .= "<h3>{$key}</h3>" . $section;
}
// Get the template name:
$mc_template = mailchimp_campaign_get_template($this->mc_data->settings->template_id);
$mc_template_name = isset($mc_template) ? $mc_template->name : '';
$list_segment_name = 'N/A';
$list_segments = mailchimp_campaign_get_list_segments($this->list->id, 'saved');
if (isset($this->mc_data->recipients->segment_opts->saved_segment_id)) {
foreach ($list_segments as $list_segment) {
if ($list_segment->id == $this->mc_data->recipients->segment_opts->saved_segment_id) {
$list_segment_name = $list_segment->name;
}
}
}
$send_time = 'N/A';
if (isset($this->mc_data->send_time) && $this->mc_data->send_time) {
$send_time = format_date(strtotime($this->mc_data->send_time), 'custom', 'F j, Y - g:ia');
}
$fields = array(
'subject' => array(
'label' => t('Subject'),
'value' => $this->mc_data->settings->subject_line,
),
'list' => array(
'label' => t('Mailchimp List'),
'value' => l($this->list->name, 'https://admin.mailchimp.com/lists/', array(
'attributes' => array(
'target' => '_blank',
),
)),
),
'list_segment' => array(
'label' => t('List Segment'),
'value' => $list_segment_name,
),
'from_email' => array(
'label' => t('From Email'),
'value' => $this->mc_data->settings->reply_to,
),
'from_name' => array(
'label' => t('From Name'),
'value' => $this->mc_data->settings->from_name,
),
'template' => array(
'label' => t('Template'),
'value' => $mc_template_name,
),
'type' => array(
'label' => t('List type'),
'value' => $this->mc_data->type,
),
'status' => array(
'label' => t('Status'),
'value' => $this->mc_data->status,
),
'emails_sent' => array(
'label' => t('Emails sent'),
'value' => $this->mc_data->emails_sent,
),
'send_time' => array(
'label' => t('Send time'),
'value' => $send_time,
),
'content' => array(
'label' => t('Rendered template HTML (!archive)', array(
'!archive' => l(t('View Mailchimp archive'), $this->mc_data->archive_url, array(
'attributes' => array(
'target' => '_blank',
),
)),
)),
'value' => $rendered,
),
);
foreach ($fields as $key => $field) {
$build[$key] = array(
'#prefix' => "<div class=\"field campaign-{$key}\"><div class=\"field-label\">{$field['label']}</div>",
'#markup' => $field['value'],
'#suffix' => '</div>',
);
}
return $build;
}
/**
* Provide a label based on the campaign title.
*/
public function label() {
return $this->mc_data->settings->title;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Entity:: |
protected | property | 1 | |
Entity:: |
protected | property | ||
Entity:: |
protected | property | ||
Entity:: |
protected | property | ||
Entity:: |
protected | property | ||
Entity:: |
public | function |
Returns the bundle of the entity. Overrides EntityInterface:: |
|
Entity:: |
protected | function | Defines the entity label if the 'entity_class_label' callback is used. | 1 |
Entity:: |
protected | function | Override this in order to implement a custom default URI and specify 'entity_class_uri' as 'uri callback' hook_entity_info(). | |
Entity:: |
public | function |
Permanently deletes the entity. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Returns the info of the type of the entity. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Returns the type of the entity. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Exports the entity. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Gets the raw, translated value of a property or field. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Checks if the entity has a certain exportable status. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Returns the entity identifier, i.e. the entities name or numeric id. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Returns the internal, numeric identifier. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Checks whether the entity is the default revision. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Permanently saves the entity. Overrides EntityInterface:: |
|
Entity:: |
protected | function | Set up the object instance on construction or unserializiation. | |
Entity:: |
public | function |
Returns the uri of the entity just as entity_uri(). Overrides EntityInterface:: |
|
Entity:: |
public | function |
Generate an array for rendering the entity. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Returns the EntityMetadataWrapper of the entity. Overrides EntityInterface:: |
|
Entity:: |
public | function | Magic method to only serialize what's necessary. | |
Entity:: |
public | function | Magic method to invoke setUp() on unserialization. | |
MailChimpCampaign:: |
public | property | ||
MailChimpCampaign:: |
public | function |
Assemble html representation of the Campaign content. Overrides Entity:: |
|
MailChimpCampaign:: |
public | function |
Provide a label based on the campaign title. Overrides Entity:: |
|
MailChimpCampaign:: |
public | function |
Overrides parent::__construct(). Overrides Entity:: |