/** * Convenience method to merge if the message has a content areas template. * * @param string $templateBody the template body * @param int $messageId the message id * @param DAO $dao an instance of a DAO intended for unit testing * * @return string|false the generated HTML or false if the message does not have * a content areas template */ public static function mergeIfTemplate($templateBody, $messageId, DAO $dao = null) { if (!$templateBody) { return false; } $tm = new self($templateBody); if (!$tm->isTemplate()) { return false; } if ($dao === null) { $dao = new DAO(new DB()); } $mm = new MessageModel($messageId, $dao); return $tm->merge($mm->messageAreas()); }
public function fromCache(array $cache) { $annotations = new self(); foreach ($cache as $object => $ann) { $object = unserialize($object); $ann = array_map(function ($a) { return Annotation::fromCache($a); }, $ann); $obj = new self($ann); if ($object) { $obj->setObject($object); } $annotations->merge($obj); } return $annotations; }