/** * Cached getter relying on data * * Only creates the object if it was not cached before, calls constructor with data otherwise * then updates object properties * * @param mixed $id primary key of the object * @param array $data data to create the object from instead of loading it (used by "get all" queries) * * @return object instance */ public static function fromData($id, $data = null, $transforms = array()) { $object = static::getFromCache($id); if (!$object) { $object = new static(null, $data); } $object->fillFromDBData($data, $transforms); static::$objectCache[$id] = $object; return $object; }
/** * Cached getter relying on data * * Only creates the object if it was not cached before, calls constructor with data otherwise * then updates object properties * * @param mixed $id primary key of the object * @param array $data data to create the object from instead of loading it (used by "get all" queries) * * @return object instance */ public static function fromData($id, $data = null, $transforms = array()) { $class = get_called_class(); $object = self::getFromCache($class, $id); if (!$object) { $object = new static(null, $data); } $object->fillFromDBData($data, $transforms); self::$objectCache[$class][$id] = $object; return $object; }