/** * @param User $user_fromId * @param User $user_toId * @param int $notificationType * @param id $target * @return Notification $this * @throws Notification_Type_Is_Not_Relate_With_This_Model * @throws Notification_Type_Not_Found */ public function push($user_fromId, $user_toId, $notificationType, $target) { switch ($notificationType) { case NOTIFICATION_ITEM_WAITING_FOR_DONE_UNDONE: case NOTIFICATION_ITEM_WAITING_FOR_FEEDBACK: if (!$target instanceof Item) { throw new Notification_Type_Is_Not_Relate_With_This_Model(); } break; case NOTIFICATION_GOAL_REACHED: if (!$target instanceof Goal) { throw new Notification_Type_Is_Not_Relate_With_This_Model(); } break; default: throw new Notification_Type_Not_Found(); } $this->from = $user_fromId->getId(); $this->to = $user_toId->getId(); $this->type = $notificationType; $this->target_id = $target->getId(); return $this; }