/** * @param array $user * * @return \DanielBadura\Redmine\Api\Struct\User|\ProxyManager\Proxy\VirtualProxyInterface */ public function user(array $user) { $userRepository = $this->client->getUserRepository(); $userStruct = $this->getIdentity($user, $userRepository); if ($userStruct !== null) { return $userStruct; } $factory = new LazyLoadingValueHolderFactory(); $initializer = function (&$wrappedObject, LazyLoadingInterface $proxy, $method) use($user, $userRepository) { if ($method == 'getId' || $method == 'getName') { if (!$wrappedObject) { $wrappedObject = new User($user['id'], $user['name']); } } else { $wrappedObject = $userRepository->find($user['id']); $proxy->setProxyInitializer(null); $userRepository->getMap()->setIdentity($wrappedObject->getId(), $wrappedObject); } return true; }; $user = $factory->createProxy('DanielBadura\\Redmine\\Api\\Struct\\User', $initializer); return $user; }
/** * @param string $json * @param string $type * * @return object */ protected function deserialize($json, $type) { return $this->client->deserialize($json, $type); }