Skip to content

Commit 091eb7c

Browse files
committed
Support for developer auth, config fixes
1 parent ae042ac commit 091eb7c

File tree

2 files changed

+35
-23
lines changed

2 files changed

+35
-23
lines changed

classes/Configurator.php

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,29 @@
1414
class Configurator {
1515

1616
public static function getContainer(array $config) {
17+
// Object Retriever Definition
18+
$objectRetrieverDefinition = DI\autowire();
19+
$orConstructorParameters = [
20+
'cache_provider' => 'file',
21+
'cache_provider.file.directory' => $config['cache_dir'] . '/config',
22+
'static_config_path' => $config['uploads_dir'] . '/config',
23+
'logger' => DI\get(Logger::class)
24+
];
25+
26+
if (!isset($config['co.auth_ns']) && CredentialManager::isConfigured()) {
27+
// Access Object API via Account Gateway using local developer account
28+
$objectRetrieverDefinition->constructor($orConstructorParameters)
29+
->method('setClient', function() {
30+
return CredentialManager::getAccountContext()->getClient();
31+
}, '/ws/');
32+
} else {
33+
// Access Object API with specified namespace credentials
34+
$objectRetrieverDefinition->constructor(array_merge([
35+
'auth_ns' => $config['co.auth_ns'],
36+
'auth_secret' => $config['co.auth_secret'],
37+
], $orConstructorParameters));
38+
}
39+
1740
// Create Dependency Injection Container
1841
$builder = new DI\ContainerBuilder();
1942
$builder->addDefinitions($config);
@@ -32,22 +55,14 @@ public static function getContainer(array $config) {
3255
}
3356
return $logger;
3457
},
58+
ObjectRetriever::class => $objectRetrieverDefinition,
3559
ObjectRetrieverPool::class => DI\autowire()
36-
->constructorParameter('baseHostname', $config['co.auth_ns'])
60+
->constructorParameter('baseHostname', @$config['co.auth_ns'])
3761
->constructorParameter('options', [
3862
'cache_provider' => 'file',
3963
'cache_provider.file.directory' => $config['cache_dir'] . '/config',
4064
'static_config_path' => $config['uploads_dir'] . '/config',
4165
'logger' => DI\get(Logger::class)
42-
]),
43-
ObjectRetriever::class => DI\autowire()
44-
->constructor([
45-
'auth_ns' => $config['co.auth_ns'],
46-
'auth_secret' => $config['co.auth_secret'],
47-
'cache_provider' => 'file',
48-
'cache_provider.file.directory' => $config['cache_dir'] . '/config',
49-
'static_config_path' => $config['uploads_dir'] . '/config',
50-
'logger' => DI\get(Logger::class)
5166
])
5267
]);
5368

config.php.default

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
<?php
22

3-
return array(
4-
'enable_vhost_controllers' => false,
5-
'exclude_vhosts' => [],
6-
'debug' => false,
7-
'account_data_cache' => 'none',
8-
'object_cache' => 'file',
9-
'redis' => [],
10-
'classes' => [
11-
'cache_dir' => '/tmp/cache',
12-
'uploads_dir' => '/tmp/uploads'
13-
],
14-
'accountgateways.base_url_template' => ''
15-
);
3+
return [
4+
'uploads' => true,
5+
'client_authentication' => 'none',
6+
'mode' => 'default',
7+
'agws.data_cache' => 'file',
8+
'log.target' => 'errorlog',
9+
'log.level' => Monolog\Logger::DEBUG,
10+
'cache_dir' => sys_get_temp_dir() . '/phpMAE/cache',
11+
'uploads_dir' => sys_get_temp_dir() . '/phpMAE/uploads',
12+
];

0 commit comments

Comments
 (0)