/** * Create and initialize an object. * * <code> * $options = array( * "project_id" => 1, * "state" => Prism\Constants::PUBLISHED * ); * * $rewards = Crowdfunding\Rewards::getInstance(\JFactory::getDbo(), $options); * </code> * * @param \JDatabaseDriver $db * @param array $options * * @return null|self */ public static function getInstance(\JDatabaseDriver $db, $options = array()) { $projectId = !isset($options["project_id"]) ? 0 : $options["project_id"]; if (!isset(self::$instances[$projectId])) { $item = new Rewards($db); $item->load($options); self::$instances[$projectId] = $item; } return self::$instances[$projectId]; }
/** * Create and initialize an object. * * <code> * $options = array( * "project_id" => 1, * "state" => Prism\Constants::PUBLISHED * ); * * $rewards = Crowdfunding\Rewards::getInstance(\JFactory::getDbo(), $options); * </code> * * @param \JDatabaseDriver $db * @param array $options * * @return null|self */ public static function getInstance(\JDatabaseDriver $db, array $options = array()) { $projectId = !array_key_exists('project_id', $options) ? 0 : (int) $options['project_id']; if (!array_key_exists($projectId, self::$instances)) { $item = new Rewards($db); $item->load($options); self::$instances[$projectId] = $item; } return self::$instances[$projectId]; }