25 private static $maxCount = 4;
26 private static $cacheTtl = 3600;
48 return self::getTemplates($messageCode);
51 private static function getTemplates($messageCode =
null)
53 static $result =
null;
61 '!=TEMPLATE_TYPE' =>
null,
62 '!=TEMPLATE_ID' =>
null,
64 $userId = Security\User::current()->getId();
67 $filter[
'=CREATED_BY'] = $userId;
71 $filter[
'=MESSAGE_CODE'] = $messageCode;
74 $chains = Entity\Letter::getList(array(
75 'select' => array(
'TEMPLATE_TYPE',
'TEMPLATE_ID'),
77 'runtime' => array(
new ExpressionField(
'MAX_ID',
'MAX(%s)',
'ID')),
78 'limit' => self::$maxCount + 1,
79 'cache' => array(
'ttl' => self::$cacheTtl),
80 'group' => array(
'TEMPLATE_TYPE',
'TEMPLATE_ID'),
81 'order' => array(
'MAX_ID' =>
'DESC'),
83 foreach ($chains as $chain)
86 ->withTypeId($chain[
'TEMPLATE_TYPE'])
87 ->withId($chain[
'TEMPLATE_ID'])
95 if ($template[
'TYPE'] ===
Type::getCode(Type::BASE) && $template[
'ID'] ===
'empty')
101 $result[] = $template;
103 if (count($result) >= self::$maxCount)
static loadMessages($file)