@@ -23,30 +23,26 @@ public function load(array $configs, ContainerBuilder $container)
2323 $ config = $ this ->processConfiguration ($ configuration , $ configs );
2424
2525 $ loader = new Loader \XmlFileLoader ($ container , new FileLocator (__DIR__ .'/../Resources/config ' ));
26- $ loader ->load ('tmdb.xml ' );
27-
28- if (!isset ($ config ['api_key ' ])) {
29- throw new \InvalidArgumentException (
30- 'The "api_key" option must be set '
31- );
32- }
26+ $ loader ->load ('services.xml ' );
3327
3428 $ container ->setParameter ('wtfz_tmdb.api_key ' , $ config ['api_key ' ]);
3529
36- if (array_key_exists ('cache ' , $ config )) {
37- $ cacheEnabled = array_key_exists ('enabled ' , $ config ['cache ' ]) && $ config ['cache ' ]['enabled ' ];
38- $ cachePath = array_key_exists ('path ' , $ config ['cache ' ]) ? $ config ['cache ' ]['path ' ] : null ;
30+ if ($ config ['cache ' ]['enabled ' ]) {
31+ $ path = $ container ->getParameterBag ()->resolveValue ($ config ['cache ' ]['path ' ]);
32+ $ container ->getDefinition ('wtfz_tmdb.client ' )->addMethodCall ('setCaching ' , array (true , $ path ));
33+ }
3934
40- $ container ->setParameter ('wtfz_tmdb.cache.enabled ' , $ cacheEnabled );
41- $ container ->setParameter ('wtfz_tmdb.cache.path ' , $ cachePath );
35+ if ($ config ['log ' ]['enabled ' ]) {
36+ $ path = $ container ->getParameterBag ()->resolveValue ($ config ['log ' ]['path ' ]);
37+ $ container ->getDefinition ('wtfz_tmdb.client ' )->addMethodCall ('setLogging ' , array (true , $ path ));
4238 }
4339
44- if (array_key_exists ( ' log ' , $ config) ) {
45- $ logEnabled = array_key_exists ( ' enabled ' , $ config [ ' log ' ]) && $ config [ ' log ' ][ ' enabled ' ] ;
46- $ logPath = array_key_exists ( ' path ' , $ config [ ' log ' ]) ? $ config [ ' log ' ][ ' path ' ] : null ;
40+ if ($ config[ ' repositories ' ][ ' enabled ' ] ) {
41+ $ loader -> load ( ' repositories.xml ' ) ;
42+ }
4743
48- $ container -> setParameter ( ' wtfz_tmdb.log. enabled ', $ logEnabled );
49- $ container -> setParameter ( ' wtfz_tmdb.log.path ' , $ logPath );
44+ if ( $ config [ ' twig_extension ' ][ ' enabled ']) {
45+ $ loader -> load ( ' twig.xml ' );
5046 }
5147 }
5248}
0 commit comments