public static function notify(Member $from, Member $to, $body, array $options = null) { $notificationItem = array('id' => microtime(), 'body' => $body, 'member_id_from' => $from->getId(), 'created_at' => time(), 'unread' => true, 'category' => $options['category'] ? $options['category'] : 'other', 'url' => $options['url'] ? $options['url'] : null, 'icon_url' => $options['icon_url'] ? $options['icon_url'] : null); $notificationObject = Doctrine::getTable('MemberConfig')->findOneByMemberIdAndName($to->getId(), 'notification_center'); if (!$notificationObject) { $notificationObject = new MemberConfig(); $notificationObject->setMemberId($to->getId()); $notificationObject->setName('notification_center'); $notifications = array(); } else { $notifications = unserialize($notificationObject->getValue()); } array_unshift($notifications, $notificationItem); $notificationLimit = sfConfig::get('op_notification_limit', 20); if ($notificationLimit < count($notifications)) { $notifications = array_slice($notifications, 0, $notificationLimit); } $notificationObject->setValue(serialize($notifications)); $notificationObject->save(); $notificationObject->free(true); }