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); } }
/** * @param DrillSchemaEvent $drillSchemaEvent * @param License $license * * @return \DateTime */ private function calculateSendDate(DrillSchemaEvent $drillSchemaEvent, License $license) { $shift = $drillSchemaEvent->getDateShift(); if ('startDate' == $drillSchemaEvent->getDateField()) { $direction = '+'; $licenseDate = $license->getStartDate(); } else { // endDate, negative shift $direction = '-'; $licenseDate = $license->getEndDate(); } $sendDate = new \DateTime(); $sendDate->setTimestamp($licenseDate->getTimestamp()); $sendDate->modify($direction . $shift . ' days'); return $sendDate; }