/** * Create an object and load user badge. * * <code> * $keys = array( * "user_id" => 1, * "group_id" => 2 * ); * $userBadge = Gamification\User\Badge::getInstance(\JFactory::getDbo(), $keys); * </code> * * @param \JDatabaseDriver $db * @param array $keys * @param array $options * * @return null|self */ public static function getInstance(\JDatabaseDriver $db, array $keys, array $options = array()) { $userId = ArrayHelper::getValue($keys, "user_id"); $groupId = ArrayHelper::getValue($keys, "group_id"); $index = md5($userId . ":" . $groupId); if (!isset(self::$instances[$index])) { $item = new Badge($db); $item->load($keys, $options); self::$instances[$index] = $item; } return self::$instances[$index]; }