/** * */ protected static function getClient(\GO\Base\Model\User $user = null) { if (!isset($user)) { $user = \GO::user(); } if (!isset(self::$client[$user->id])) { $dbxUser = User::model()->findByPk($user->id); if (!$dbxUser) { throw new \Exception("User isn't connected"); } if (empty($dbxUser->access_token)) { throw new \Exception("Access token was cleared. Please reconnect."); } $client = new DropboxClient(); $client->SetAccessToken(@unserialize($dbxUser->access_token)); self::$client[$user->id] = $client; } return self::$client[$user->id]; }