|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Created by PhpStorm. |
|
4
|
|
|
* User: siim |
|
5
|
|
|
* Date: 26.02.19 |
|
6
|
|
|
* Time: 10:01 |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace Sf4\Api\DependencyInjection; |
|
10
|
|
|
|
|
11
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
|
12
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
|
13
|
|
|
|
|
14
|
|
|
class Configuration implements ConfigurationInterface |
|
15
|
|
|
{ |
|
16
|
|
|
|
|
17
|
|
|
public const NAME = 'sf4_api'; |
|
18
|
|
|
public const SITES = 'sites'; |
|
19
|
|
|
public const SITES_SITE = 'site'; |
|
20
|
|
|
public const SITES_URL = 'url'; |
|
21
|
|
|
public const SITES_TOKEN = 'token'; |
|
22
|
|
|
public const ROUTES = 'routes'; |
|
23
|
|
|
public const ROUTES_ROUTE = 'route'; |
|
24
|
|
|
public const ROUTES_REQUEST_CLASS = 'request_class'; |
|
25
|
|
|
public const ENTITIES = 'entities'; |
|
26
|
|
|
public const ENTITIES_TABLE_NAME = 'table_name'; |
|
27
|
|
|
public const ENTITIES_ENTITY_CLASS = 'entity_class'; |
|
28
|
|
|
|
|
29
|
|
|
public function getConfigTreeBuilder(): TreeBuilder |
|
30
|
|
|
{ |
|
31
|
|
|
$treeBuilder = new TreeBuilder(); |
|
32
|
|
|
$rootNode = $treeBuilder->root(static::NAME); |
|
33
|
|
|
|
|
34
|
|
|
$children = $rootNode->children(); |
|
35
|
|
|
|
|
36
|
|
|
$sites = $children->arrayNode(static::SITES)->arrayPrototype()->children(); |
|
37
|
|
|
$sites->scalarNode(static::SITES_SITE)->end(); |
|
38
|
|
|
$sites->scalarNode(static::SITES_URL)->end(); |
|
39
|
|
|
$sites->scalarNode(static::SITES_TOKEN)->end(); |
|
40
|
|
|
$sites->end()->end(); |
|
41
|
|
|
$sites->end(); |
|
42
|
|
|
|
|
43
|
|
|
$routes = $children->arrayNode(static::ROUTES)->arrayPrototype()->children(); |
|
44
|
|
|
$routes->scalarNode(static::ROUTES_ROUTE)->end(); |
|
45
|
|
|
$routes->scalarNode(static::ROUTES_REQUEST_CLASS)->end(); |
|
46
|
|
|
$routes->end()->end(); |
|
47
|
|
|
$routes->end(); |
|
48
|
|
|
|
|
49
|
|
|
$entities = $children->arrayNode(static::ENTITIES)->arrayPrototype()->children(); |
|
50
|
|
|
$entities->scalarNode(static::ENTITIES_TABLE_NAME)->end(); |
|
51
|
|
|
$entities->scalarNode(static::ENTITIES_ENTITY_CLASS)->end(); |
|
52
|
|
|
$entities->end()->end(); |
|
53
|
|
|
$entities->end(); |
|
54
|
|
|
|
|
55
|
|
|
$children->end(); |
|
56
|
|
|
|
|
57
|
|
|
return $treeBuilder; |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|