/** * Get the variant parent/children * * @param Email $email * * @return array */ public function getVariants(Email $email) { $parent = $email->getVariantParent(); if (!empty($parent)) { $children = $parent->getVariantChildren(); } else { $parent = $email; $children = $email->getVariantChildren(); } if (empty($children)) { $children = array(); } return array($parent, $children); }
/** * Get the number of leads this email will be sent to * * @param Email $email * @param mixed $listId Leads for a specific lead list * @param bool $countOnly If true, return count otherwise array of leads * @param int $limit Max number of leads to retrieve * @param bool $includeVariants If false, emails sent to a variant will not be included * * @return int|array */ public function getPendingLeads(Email $email, $listId = null, $countOnly = false, $limit = null, $includeVariants = true) { if ($includeVariants && $email->isVariant()) { $parent = $email->getVariantParent(); if ($parent) { // $email is a variant of another $ids[] = $parent->getId(); $children = $parent->getVariantChildren(); $variantIds = $children->getKeys(); // Remove $email from the array $key = array_search($email->getId(), $variantIds); unset($variantIds[$key]); } else { $children = $email->getVariantChildren(); $variantIds = $children->getKeys(); } } else { $variantIds = null; } $total = $this->getRepository()->getEmailPendingLeads($email->getId(), $variantIds, $listId, $countOnly, $limit); return $total; }
/** * {@inheritDoc} */ public function getVariantParent() { $this->__initializer__ && $this->__initializer__->__invoke($this, 'getVariantParent', array()); return parent::getVariantParent(); }