protected static function replaceTemplateVariables(&$html, License $license) { $mapping = ['%_TECH_CONTACT_%' => $license->getTechContactName(), '%_TECH_CONTACT_FIRST_NAME_%' => self::getFirstName($license->getTechContactName()), '%_ADDON_NAME_%' => $license->getAddonName(), '%_ADDON_KEY_%' => $license->getAddonKey(), '%_LICENSE_ID_%' => $license->getLicenseId(), '%_ADDON_URL_%' => self::buildAddonURL($license->getAddonKey()), '%_LICENSE_START_DATE_%' => $license->getStartDate()->format('Y-m-d'), '%_LICENSE_END_DATE_%' => $license->getEndDate()->format('Y-m-d')]; foreach ($mapping as $token => $replacement) { $html = str_replace($token, $replacement, $html); } }
/** * Adds new subscriber to the mailchimp list * * Works only if the license is new (checks for the empty id) * * @param License $license */ public function addToList(License $license) { if (!$this->enabled) { return; } foreach ($this->lists as $list) { if ($license->isNew() && $license->getAddonKey() == $list['addon_key']) { $this->add($list['list_id'], $license); } } }