/** * Fetches a frozen object from the object storage and thaws it. * * @param string $id The ID of the object that is to be fetched. * * @return object */ public function fetch($id) { // Bail out if a non-string was passed. if (!is_string($id)) { throw Object_Freezer_Util::getInvalidArgumentException(1, 'string'); } // Try to retrieve object from the object cache. $object = $this->cache->get($id); if (!$object) { // Retrieve object from the object storage. $frozenObject = $this->doFetch($id); $this->fetchArray($frozenObject['objects'][$id]['state']); $object = $this->freezer->thaw($frozenObject); // Put object into the object cache. $this->cache->put($id, $object); } return $object; }
/** * thaws a frozen user * @param Array $frozenUser * @return User $user returns User Object or null if user could not be thawed */ public static function thaw($frozenUser) { $thawedUser = null; if (is_array($frozenUser)) { $freezer = new Object_Freezer(); $thawedUser = $freezer->thaw($frozenUser); if ($thawedUser instanceof User) { $thawedUser->getResource()->getById($thawedUser->getId()); //TODO: do we need to reinitialize parent's resources? } else { $thawedUser = null; Logger::error("could not thaw user"); } } return $thawedUser; }