@@ -33,87 +33,141 @@ public function load(array $configs, ContainerBuilder $container)
33
33
$ config = $ this ->processConfiguration (new Configuration (), $ configs );
34
34
$ loader = new XmlFileLoader ($ container , new FileLocator (__DIR__ .'/../Resources/config ' ));
35
35
36
- $ container ->setParameter ($ this ->getAlias () . '.basepath ' , $ config ['basepath ' ]);
37
- $ container ->setParameter ($ this ->getAlias () . '.menu_basepath ' , PathHelper::getParentPath ($ config ['basepath ' ]));
38
- $ container ->setParameter ($ this ->getAlias () . '.uri_filter_regexp ' , $ config ['routing ' ]['uri_filter_regexp ' ]);
36
+ $ this ->loadRouting ($ config ['routing ' ], $ loader , $ container );
37
+
38
+ if (isset ($ config ['persistence ' ])) {
39
+ if (isset ($ config ['persistence ' ]['phpcr ' ])) {
40
+ $ this ->loadPhpcr ($ config ['persistence ' ]['phpcr ' ], $ loader , $ container );
41
+ $ this ->loadPhpcrRouting ($ config , $ loader , $ container );
42
+
43
+ if ($ config ['use_menu ' ]) {
44
+ $ this ->loadPhpcrMenu ($ config , $ loader , $ container );
45
+ }
46
+ }
47
+ }
48
+ }
49
+
50
+ protected function loadRouting ($ config , XmlFileLoader $ loader , ContainerBuilder $ container )
51
+ {
52
+ $ container ->setParameter ($ this ->getAlias () . '.uri_filter_regexp ' , $ config ['uri_filter_regexp ' ]);
39
53
40
54
$ loader ->load ('routing.xml ' );
41
- $ loader ->load ('migrator.xml ' );
42
55
43
56
$ dynamic = $ container ->getDefinition ($ this ->getAlias ().'.dynamic_router ' );
44
57
45
58
if (!empty ($ config ['generic_controller ' ])) {
46
59
$ definition = new DefinitionDecorator ('cmf_routing.enhancer_explicit_template ' );
47
60
$ definition ->replaceArgument (2 , $ config ['generic_controller ' ]);
48
- $ container ->setDefinition ($ this ->getAlias () . '.enhancer_explicit_template ' , $ definition );
49
- $ dynamic ->addMethodCall ('addRouteEnhancer ' , array (new Reference ($ this ->getAlias () . '.enhancer_explicit_template ' )));
61
+ $ container ->setDefinition (
62
+ $ this ->getAlias () . '.enhancer_explicit_template ' ,
63
+ $ definition
64
+ );
65
+ $ dynamic ->addMethodCall ('addRouteEnhancer ' , array (
66
+ new Reference ($ this ->getAlias () . '.enhancer_explicit_template ' )
67
+ ));
50
68
}
51
- if (!empty ($ config ['routing ' ]['controllers_by_alias ' ])) {
69
+
70
+ if (!empty ($ config ['controllers_by_alias ' ])) {
52
71
$ definition = new DefinitionDecorator ('cmf_routing.enhancer_controllers_by_class ' );
53
72
$ definition ->replaceArgument (2 , $ config ['routing ' ]['controllers_by_alias ' ]);
54
- $ container ->setDefinition ($ this ->getAlias () . '.enhancer_controllers_by_class ' , $ definition );
55
- $ dynamic ->addMethodCall ('addRouteEnhancer ' , array (new Reference ($ this ->getAlias () . '.enhancer_controllers_by_alias ' )));
73
+ $ container ->setDefinition (
74
+ $ this ->getAlias () . '.enhancer_controllers_by_class ' ,
75
+ $ definition
76
+ );
77
+ $ dynamic ->addMethodCall ('addRouteEnhancer ' , array (
78
+ new Reference ($ this ->getAlias () . '.enhancer_controllers_by_alias ' )
79
+ ));
56
80
}
57
- if (!empty ($ config ['routing ' ]['controllers_by_class ' ])) {
81
+
82
+ if (!empty ($ config ['controllers_by_class ' ])) {
58
83
$ definition = new DefinitionDecorator ('cmf_routing.enhancer_controllers_by_class ' );
59
- $ definition ->replaceArgument (2 , $ config ['routing ' ]['controllers_by_class ' ]);
60
- $ container ->setDefinition ($ this ->getAlias () . '.enhancer_controllers_by_class ' , $ definition );
61
- $ dynamic ->addMethodCall ('addRouteEnhancer ' , array (new Reference ($ this ->getAlias () . '.enhancer_controllers_by_class ' )));
84
+ $ definition ->replaceArgument (2 , $ config ['controllers_by_class ' ]);
85
+ $ container ->setDefinition (
86
+ $ this ->getAlias () . '.enhancer_controllers_by_class ' ,
87
+ $ definition
88
+ );
89
+ $ dynamic ->addMethodCall ('addRouteEnhancer ' , array (
90
+ new Reference ($ this ->getAlias () . '.enhancer_controllers_by_class ' )
91
+ ));
62
92
}
63
- if (!empty ($ config ['generic_controller ' ]) && !empty ($ config ['routing ' ]['templates_by_class ' ])) {
93
+
94
+ if (!empty ($ config ['generic_controller ' ]) && !empty ($ config ['templates_by_class ' ])) {
64
95
$ controllerForTemplates = array ();
65
- foreach ($ config ['routing ' ][ ' templates_by_class ' ] as $ key => $ value ) {
96
+ foreach ($ config ['templates_by_class ' ] as $ key => $ value ) {
66
97
$ controllerForTemplates [$ key ] = $ config ['generic_controller ' ];
67
98
}
68
99
69
100
$ definition = new DefinitionDecorator ('cmf_routing.enhancer_controller_for_templates_by_class ' );
70
101
$ definition ->replaceArgument (2 , $ controllerForTemplates );
71
- $ container ->setDefinition ($ this ->getAlias () . '.enhancer_controller_for_templates_by_class ' , $ definition );
102
+
103
+ $ container ->setDefinition (
104
+ $ this ->getAlias () . '.enhancer_controller_for_templates_by_class ' ,
105
+ $ definition
106
+ );
107
+
72
108
$ definition = new DefinitionDecorator ('cmf_routing.enhancer_templates_by_class ' );
73
- $ definition ->replaceArgument (2 , $ config ['routing ' ]['templates_by_class ' ]);
74
- $ container ->setDefinition ($ this ->getAlias () . '.enhancer_templates_by_class ' , $ definition );
75
- $ dynamic ->addMethodCall ('addRouteEnhancer ' , array (new Reference ($ this ->getAlias () . '.enhancer_controller_for_templates_by_class ' )));
76
- $ dynamic ->addMethodCall ('addRouteEnhancer ' , array (new Reference ($ this ->getAlias () . '.enhancer_templates_by_class ' )));
109
+ $ definition ->replaceArgument (2 , $ config ['templates_by_class ' ]);
110
+
111
+ $ container ->setDefinition (
112
+ $ this ->getAlias () . '.enhancer_templates_by_class ' ,
113
+ $ definition
114
+ );
115
+
116
+ $ dynamic ->addMethodCall ('addRouteEnhancer ' , array (
117
+ new Reference ($ this ->getAlias () . '.enhancer_controller_for_templates_by_class ' )
118
+ ));
119
+ $ dynamic ->addMethodCall ('addRouteEnhancer ' , array (
120
+ new Reference ($ this ->getAlias () . '.enhancer_templates_by_class ' )
121
+ ));
77
122
}
123
+ }
78
124
79
- $ generator = $ container ->getDefinition ($ this ->getAlias ().'.generator ' );
80
- $ generator ->addMethodCall ('setContentRepository ' , array (new Reference ($ config ['routing ' ]['content_repository_id ' ])));
81
-
82
- $ container ->setParameter ($ this ->getAlias () . '.manager_name ' , $ config ['manager_name ' ]);
83
- $ routeProvider = $ container ->getDefinition ($ this ->getAlias () . '.route_provider ' );
84
- $ routeProvider ->replaceArgument (0 , new Reference ($ config ['manager_registry ' ]));
85
- $ multilangRouteProvider = $ container ->getDefinition ($ this ->getAlias () . '.multilang_route_provider ' );
86
- $ multilangRouteProvider ->replaceArgument (0 , new Reference ($ config ['manager_registry ' ]));
87
-
88
- if (!empty ($ config ['multilang ' ])) {
89
- $ container ->setParameter ($ this ->getAlias () . '.locales ' , $ config ['multilang ' ]['locales ' ]);
90
- $ container ->setAlias ('cmf_simple_cms.route_provider ' , 'cmf_simple_cms.multilang_route_provider ' );
91
- if ('Symfony\Cmf\Bundle\SimpleCmsBundle\Document\Page ' === $ config ['document_class ' ]) {
92
- $ config ['document_class ' ] = 'Symfony\Cmf\Bundle\SimpleCmsBundle\Document\MultilangPage ' ;
93
- }
94
- }
125
+ protected function loadPhpcr ($ config , XmlFileLoader $ loader , ContainerBuilder $ container )
126
+ {
127
+ // migrator is only for PHPCR
128
+ $ loader ->load ('migrator.xml ' );
95
129
96
- $ container ->setParameter ($ this ->getAlias () . '.document_class ' , $ config ['document_class ' ]);
130
+ // save some characters
131
+ $ prefix = $ this ->getAlias () . '.persistence.phpcr ' ;
97
132
98
- if ( $ config ['use_menu ' ]) {
99
- $ this -> loadMenu ( $ config , $ loader , $ container );
100
- }
133
+ $ container -> setParameter ( $ prefix . ' .basepath ' , $ config ['basepath ' ]);
134
+
135
+ $ container -> setParameter ( $ prefix . ' .menu_basepath ' , PathHelper:: getParentPath ( $ config [ ' basepath ' ]));
101
136
102
137
if ($ config ['use_sonata_admin ' ]) {
103
138
$ this ->loadSonataAdmin ($ config , $ loader , $ container );
104
139
} elseif (isset ($ config ['sonata_admin ' ])) {
105
140
throw new InvalidConfigurationException ('Do not define sonata_admin options when use_sonata_admin is set to false ' );
106
141
}
142
+
143
+ $ container ->setParameter ($ prefix . '.manager_name ' , $ config ['manager_name ' ]);
144
+
145
+ $ container ->setParameter ($ prefix . '.document_class ' , $ config ['document_class ' ]);
146
+ }
147
+
148
+ protected function loadPhpcrRouting ($ config , XmlFileLoader $ loader , ContainerBuilder $ container )
149
+ {
150
+ $ loader ->load ('routing-phpcr.xml ' );
151
+ $ prefix = $ this ->getAlias () . '.persistence.phpcr ' ;
152
+
153
+ $ routeProvider = $ container ->getDefinition ($ prefix .'.route_provider ' );
154
+ $ routeProvider ->replaceArgument (0 , new Reference ($ config ['persistence ' ]['phpcr ' ]['manager_registry ' ]));
155
+ $ container ->setAlias ($ this ->getAlias () . '.route_provider ' , $ prefix .'.route_provider ' );
156
+
157
+ $ generator = $ container ->getDefinition ($ this ->getAlias ().'.generator ' );
158
+ $ generator ->addMethodCall ('setContentRepository ' , array (
159
+ new Reference ($ config ['routing ' ]['content_repository_id ' ])
160
+ ));
107
161
}
108
162
109
- protected function loadMenu ($ config , XmlFileLoader $ loader , ContainerBuilder $ container )
163
+ protected function loadPhpcrMenu ($ config , XmlFileLoader $ loader , ContainerBuilder $ container )
110
164
{
111
165
$ bundles = $ container ->getParameter ('kernel.bundles ' );
112
166
if ('auto ' === $ config ['use_menu ' ] && !isset ($ bundles ['CmfMenuBundle ' ])) {
113
167
return ;
114
168
}
115
169
116
- $ loader ->load ('menu.xml ' );
170
+ $ loader ->load ('menu-phpcr .xml ' );
117
171
}
118
172
119
173
protected function loadSonataAdmin ($ config , XmlFileLoader $ loader , ContainerBuilder $ container )
@@ -123,10 +177,10 @@ protected function loadSonataAdmin($config, XmlFileLoader $loader, ContainerBuil
123
177
return ;
124
178
}
125
179
126
- $ container ->setParameter ($ this ->getAlias () . '.admin.sort ' ,
180
+ $ container ->setParameter ($ this ->getAlias () . '.persistence.phpcr. admin.sort ' ,
127
181
isset ($ config ['sonata_admin ' ])
128
- ? $ config ['sonata_admin ' ]['sort ' ]
129
- : false
182
+ ? $ config ['sonata_admin ' ]['sort ' ]
183
+ : false
130
184
);
131
185
132
186
$ loader ->load ('admin.xml ' );
0 commit comments