@@ -32,9 +32,32 @@ class CmfSimpleCmsExtension extends Extension implements PrependExtensionInterfa
3232 */
3333 public function prepend (ContainerBuilder $ container )
3434 {
35- $ prependConfig = array ('persistence ' => array ('phpcr ' => (array ('enabled ' => true ))));
36- $ container ->prependExtensionConfig ('cmf_menu ' , $ prependConfig );
37- $ prependConfig = array ('dynamic ' => $ prependConfig );
35+ // process the configuration of CmfCoreExtension
36+ $ configs = $ container ->getExtensionConfig ($ this ->getAlias ());
37+ $ parameterBag = $ container ->getParameterBag ();
38+ $ configs = $ parameterBag ->resolveValue ($ configs );
39+ $ config = $ this ->processConfiguration (new Configuration (), $ configs );
40+
41+ if (empty ($ config ['persistence ' ]['phpcr ' ]['enabled ' ])) {
42+ return ;
43+ }
44+
45+ $ prependConfig = array (
46+ 'chain ' => array (
47+ 'routers_by_id ' => array (
48+ 'router.default ' => 0 ,
49+ 'cmf_routing.dynamic_router ' => -100 ,
50+ )
51+ ),
52+ 'dynamic ' => array (
53+ 'enabled ' => true ,
54+ )
55+ );
56+ if (isset ($ config ['persistence ' ]['phpcr ' ]['basepath ' ])
57+ && '/cms/simple ' != $ config ['persistence ' ]['phpcr ' ]['basepath ' ]
58+ ) {
59+ $ prependConfig ['dynamic ' ]['persistence ' ]['phpcr ' ]['route_basepaths ' ] = array ($ config ['persistence ' ]['phpcr ' ]['basepath ' ]);
60+ }
3861 $ container ->prependExtensionConfig ('cmf_routing ' , $ prependConfig );
3962 }
4063
@@ -43,101 +66,20 @@ public function load(array $configs, ContainerBuilder $container)
4366 $ config = $ this ->processConfiguration (new Configuration (), $ configs );
4467 $ loader = new XmlFileLoader ($ container , new FileLocator (__DIR__ .'/../Resources/config ' ));
4568
46- $ this ->loadRouting ($ config ['routing ' ], $ loader , $ container );
47-
4869 if ($ config ['persistence ' ]['phpcr ' ]) {
4970 $ this ->loadPhpcr ($ config ['persistence ' ]['phpcr ' ], $ loader , $ container );
50- $ locales = isset ($ config ['multilang ' ]['locales ' ]) ? $ config ['multilang ' ]['locales ' ] : false ;
51- $ this ->loadPhpcrRouting ($ config , $ loader , $ container , $ locales );
5271
5372 if ($ config ['use_menu ' ]) {
5473 $ this ->loadPhpcrMenu ($ config , $ loader , $ container );
5574 }
5675 }
5776 }
5877
59- protected function loadRouting ($ config , XmlFileLoader $ loader , ContainerBuilder $ container )
60- {
61- $ container ->setParameter ($ this ->getAlias () . '.uri_filter_regexp ' , $ config ['uri_filter_regexp ' ]);
62-
63- $ loader ->load ('routing.xml ' );
64-
65- $ dynamic = $ container ->getDefinition ($ this ->getAlias ().'.dynamic_router ' );
66-
67- if (!empty ($ config ['generic_controller ' ])) {
68- $ definition = new DefinitionDecorator ('cmf_routing.enhancer.explicit_template ' );
69- $ definition ->replaceArgument (2 , $ config ['generic_controller ' ]);
70- $ container ->setDefinition (
71- $ this ->getAlias () . '.enhancer.explicit_template ' ,
72- $ definition
73- );
74- $ dynamic ->addMethodCall ('addRouteEnhancer ' , array (
75- new Reference ($ this ->getAlias () . '.enhancer.explicit_template ' )
76- ));
77- }
78-
79- if (!empty ($ config ['controllers_by_type ' ])) {
80- $ definition = new DefinitionDecorator ('cmf_routing.enhancer.controllers_by_type ' );
81- $ definition ->replaceArgument (2 , $ config ['controllers_by_type ' ]);
82- $ container ->setDefinition (
83- $ this ->getAlias () . '.enhancer.controllers_by_type ' ,
84- $ definition
85- );
86- $ dynamic ->addMethodCall ('addRouteEnhancer ' , array (
87- new Reference ($ this ->getAlias () . '.enhancer.controllers_by_type ' )
88- ));
89- }
90-
91- if (!empty ($ config ['controllers_by_class ' ])) {
92- $ definition = new DefinitionDecorator ('cmf_routing.enhancer.controllers_by_class ' );
93- $ definition ->replaceArgument (2 , $ config ['controllers_by_class ' ]);
94- $ container ->setDefinition (
95- $ this ->getAlias () . '.enhancer.controllers_by_class ' ,
96- $ definition
97- );
98- $ dynamic ->addMethodCall ('addRouteEnhancer ' , array (
99- new Reference ($ this ->getAlias () . '.enhancer.controllers_by_class ' )
100- ));
101- }
102-
103- if (!empty ($ config ['generic_controller ' ]) && !empty ($ config ['templates_by_class ' ])) {
104- $ controllerForTemplates = array ();
105- foreach ($ config ['templates_by_class ' ] as $ key => $ value ) {
106- $ controllerForTemplates [$ key ] = $ config ['generic_controller ' ];
107- }
108-
109- $ definition = new DefinitionDecorator ('cmf_routing.enhancer.controller_for_templates_by_class ' );
110- $ definition ->replaceArgument (2 , $ controllerForTemplates );
111-
112- $ container ->setDefinition (
113- $ this ->getAlias () . '.enhancer.controller_for_templates_by_class ' ,
114- $ definition
115- );
116-
117- $ definition = new DefinitionDecorator ('cmf_routing.enhancer.templates_by_class ' );
118- $ definition ->replaceArgument (2 , $ config ['templates_by_class ' ]);
119-
120- $ container ->setDefinition (
121- $ this ->getAlias () . '.enhancer.templates_by_class ' ,
122- $ definition
123- );
124-
125- $ dynamic ->addMethodCall ('addRouteEnhancer ' , array (
126- new Reference ($ this ->getAlias () . '.enhancer.controller_for_templates_by_class ' )
127- ));
128- $ dynamic ->addMethodCall ('addRouteEnhancer ' , array (
129- new Reference ($ this ->getAlias () . '.enhancer.templates_by_class ' )
130- ));
131- }
132- }
133-
13478 protected function loadPhpcr ($ config , XmlFileLoader $ loader , ContainerBuilder $ container )
13579 {
13680 $ loader ->load ('services-phpcr.xml ' );
137- // migrator is only for PHPCR
13881 $ loader ->load ('migrator-phpcr.xml ' );
13982
140- // save some characters
14183 $ prefix = $ this ->getAlias () . '.persistence.phpcr ' ;
14284
14385 $ container ->setParameter ($ prefix . '.basepath ' , $ config ['basepath ' ]);
@@ -155,24 +97,6 @@ protected function loadPhpcr($config, XmlFileLoader $loader, ContainerBuilder $c
15597 $ container ->setParameter ($ prefix . '.document.class ' , $ config ['document_class ' ]);
15698 }
15799
158- protected function loadPhpcrRouting ($ config , XmlFileLoader $ loader , ContainerBuilder $ container , $ locales )
159- {
160- $ loader ->load ('routing-phpcr.xml ' );
161- $ prefix = $ this ->getAlias () . '.persistence.phpcr ' ;
162-
163- $ routeProvider = $ container ->getDefinition ($ prefix .'.route_provider ' );
164- $ routeProvider ->replaceArgument (0 , new Reference ($ config ['persistence ' ]['phpcr ' ]['manager_registry ' ]));
165- if (!empty ($ locales )) {
166- $ routeProvider ->addMethodCall ('setLocales ' , array ($ locales ));
167- }
168- $ container ->setAlias ($ this ->getAlias () . '.route_provider ' , $ prefix .'.route_provider ' );
169-
170- $ generator = $ container ->getDefinition ($ this ->getAlias ().'.generator ' );
171- $ generator ->addMethodCall ('setContentRepository ' , array (
172- new Reference ($ config ['routing ' ]['content_repository_id ' ])
173- ));
174- }
175-
176100 protected function loadPhpcrMenu ($ config , XmlFileLoader $ loader , ContainerBuilder $ container )
177101 {
178102 $ bundles = $ container ->getParameter ('kernel.bundles ' );
0 commit comments