1 | <?php |
||
15 | class Configuration implements ConfigurationInterface |
||
16 | { |
||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | protected $shmop_salt = ''; |
||
21 | |||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $file_path = ''; |
||
26 | |||
27 | /** |
||
28 | * @param string $shmop_salt |
||
29 | * @param string $file_path |
||
30 | */ |
||
31 | 1 | public function __construct($shmop_salt, $file_path) |
|
36 | |||
37 | /** |
||
38 | * Config tree builder. |
||
39 | * |
||
40 | * Example config: |
||
41 | * |
||
42 | * anime_db_cache_time_keeper: |
||
43 | * use_driver: file |
||
44 | * drivers: |
||
45 | * multi: |
||
46 | * fast: shmop |
||
47 | * slow: file |
||
48 | * shmop: |
||
49 | * salt: '%secret%' |
||
50 | * file: |
||
51 | * path: '%kernel.root_dir%/cache/cache-time-keeper/' |
||
52 | * memcached: |
||
53 | * prefix: 'cache_time_keeper_' |
||
54 | * persistent_id: 'cache_time_keeper' |
||
55 | * hosts: |
||
56 | * - {host: 'localhost', port: 11211, weight: 100} |
||
57 | * |
||
58 | * @return TreeBuilder |
||
59 | */ |
||
60 | 1 | public function getConfigTreeBuilder() |
|
61 | { |
||
62 | 1 | $tree_builder = new TreeBuilder(); |
|
63 | $tree_builder |
||
64 | 1 | ->root('anime_db_cache_time_keeper') |
|
65 | 1 | ->children() |
|
66 | 1 | ->scalarNode('use_driver') |
|
67 | 1 | ->cannotBeEmpty() |
|
68 | 1 | ->defaultValue('file') |
|
69 | 1 | ->end() |
|
70 | 1 | ->arrayNode('drivers') |
|
71 | 1 | ->append($this->getDriverFile()) |
|
72 | 1 | ->append($this->getDriverMemcached()) |
|
73 | 1 | ->append($this->getDriverMulti()) |
|
74 | 1 | ->append($this->getDriverShmop()) |
|
75 | 1 | ->end() |
|
76 | 1 | ->end(); |
|
77 | |||
78 | 1 | return $tree_builder; |
|
79 | } |
||
80 | |||
81 | /** |
||
82 | * @return ArrayNodeDefinition |
||
83 | */ |
||
84 | 1 | protected function getDriverMulti() |
|
101 | |||
102 | /** |
||
103 | * @return ArrayNodeDefinition |
||
104 | */ |
||
105 | 1 | protected function getDriverShmop() |
|
118 | |||
119 | /** |
||
120 | * @return ArrayNodeDefinition |
||
121 | */ |
||
122 | 1 | protected function getDriverFile() |
|
135 | |||
136 | /** |
||
137 | * @return ArrayNodeDefinition |
||
138 | */ |
||
139 | 1 | protected function getDriverMemcached() |
|
188 | } |
||
189 |