-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathConfiguration.php
58 lines (51 loc) · 1.99 KB
/
Configuration.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
namespace Maxikg\GithubApiBundle\DependencyInjection;
use Github\Client;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
class Configuration implements ConfigurationInterface
{
const AUTHENTICATION_DISABLED = 'none';
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('github_api');
$rootNode
->children()
->arrayNode('cache')
->addDefaultsIfNotSet()
->children()
->booleanNode('enabled')->defaultFalse()->end()
->scalarNode('service')->defaultValue('github.http.cache')->end()
->end()
->end()
->arrayNode('client')->end()
->scalarNode('enterprise_url')->defaultNull()->end()
->arrayNode('authentication')
->addDefaultsIfNotSet()
->children()
->enumNode('type')
->values(self::getValidAuthMethods())
->defaultValue(self::AUTHENTICATION_DISABLED)
->end()
->scalarNode('token')->defaultNull()->end()
->scalarNode('client_id')->defaultNull()->end()
->scalarNode('client_secret')->defaultNull()->end()
->scalarNode('username')->defaultNull()->end()
->scalarNode('password')->defaultNull()->end()
->end()
->end()
->end();
return $treeBuilder;
}
private static function getValidAuthMethods()
{
return array(
Client::AUTH_HTTP_PASSWORD,
Client::AUTH_HTTP_TOKEN,
Client::AUTH_URL_CLIENT_ID,
Client::AUTH_URL_TOKEN,
self::AUTHENTICATION_DISABLED
);
}
}