22 public static function create(array $params)
24 $entityTypeId = isset($params[
'ENTITY_TYPE_ID']) ? (int)$params[
'ENTITY_TYPE_ID'] : 0;
25 if($entityTypeId <= 0)
30 $entityId = isset($params[
'ENTITY_ID']) ? (int)$params[
'ENTITY_ID'] : 0;
36 $typeCategoryId = isset($params[
'TYPE_CATEGORY_ID']) ? $params[
'TYPE_CATEGORY_ID'] : 0;
42 $authorId = isset($params[
'AUTHOR_ID']) ? (int) $params[
'AUTHOR_ID'] : 0;
43 if(!is_int($authorId))
45 $authorId = (int) $authorId;
53 $created = (isset($params[
'CREATED']) && ($params[
'CREATED'] instanceof
DateTime)) ? $params[
'CREATED'] :
new DateTime();
54 $settings = isset($params[
'SETTINGS']) && is_array($params[
'SETTINGS']) ? $params[
'SETTINGS'] : array();
56 $result = TimelineTable::add(
58 'TYPE_ID' => Timeline\TimelineType::SENDER,
59 'TYPE_CATEGORY_ID' => $typeCategoryId,
60 'CREATED' => $created,
61 'AUTHOR_ID' => $authorId,
62 'SETTINGS' => $settings,
63 'ASSOCIATED_ENTITY_TYPE_ID' => $entityTypeId,
64 'ASSOCIATED_ENTITY_ID' => $entityId
68 if(!$result->isSuccess())
72 $id = $result->getId();
74 $bindings = isset($params[
'BINDINGS']) && is_array($params[
'BINDINGS']) ? $params[
'BINDINGS'] : array();
77 $bindings[] = array(
'ENTITY_TYPE_ID' => $entityTypeId,
'ENTITY_ID' => $entityId);
79 self::registerBindings($id, $bindings);