122 public static $basedir = __DIR__;
124 public static $config = array(
131 'transport' =>
'\HPCloud\Transport\CURLTransport',
138 public static $identity = NULL;
155 spl_autoload_register(__NAMESPACE__ .
'\Bootstrap::autoload');
181 $swift = stream_wrapper_register(
182 \HPCloud\Storage\ObjectStorage\StreamWrapper::DEFAULT_SCHEME,
183 '\HPCloud\Storage\ObjectStorage\StreamWrapper'
186 $swiftfs = stream_wrapper_register(
187 \HPCloud\Storage\ObjectStorage\StreamWrapperFS::DEFAULT_SCHEME,
188 '\HPCloud\Storage\ObjectStorage\StreamWrapperFS'
191 return ($swift && $swiftfs);
237 self::$config = $array + self::$config;
265 $components = explode(
'\\', $klass);
266 if (empty($components[0])) {
267 array_shift($components);
274 if ($components[0] !=
'HPCloud') {
279 $loc = DIRECTORY_SEPARATOR .
'HPCloud';
280 $local_path = substr(self::$basedir, 0, strrpos(self::$basedir, $loc));
282 array_unshift($components, $local_path);
283 $path = implode(DIRECTORY_SEPARATOR, $components) .
'.php';
285 if (file_exists($path)) {
308 return self::$config;
312 if (isset(self::$config[
$name])) {
313 return self::$config[
$name];
338 return isset(self::$config[
$name]);
359 if ($force || is_null(self::$identity) || self::$identity->isExpired()) {
362 if (!self::hasConfig(
'endpoint')) {
363 throw new Exception(
'Unable to authenticate. No endpoint supplied.');
369 $user = self::config(
'username', NULL);
370 $account = self::config(
'account', NULL);
373 if (!empty($user) && self::hasConfig(
'password')) {
375 $is->authenticateAsUser($user, self::config(
'password'), self::config(
'tenantid', NULL), self::config(
'tenantname', NULL));
376 self::$identity = $is;
380 elseif (!empty(
$account) && self::hasConfig(
'secret')) {
382 $is->authenticateAsAccount(
$account, self::config(
'secret'), self::config(
'tenantid', NULL), self::config(
'tenantname', NULL));
383 self::$identity = $is;
387 throw new Exception(
'Unable to authenticate. No account credentials supplied.');
391 return self::$identity;