@@ -103,7 +103,7 @@ node::
103
103
104
104
public function init(ManagerRegistry $registry)
105
105
{
106
- $dm = $registry->getManagerForClass('Acme\BasicCmsBundle\Document\Site' );
106
+ $dm = $registry->getManager( );
107
107
if ($dm->find(null, $this->basePath)) {
108
108
return;
109
109
}
@@ -135,8 +135,8 @@ node::
135
135
documents in initializers. With 1.0, you would need to manually set the
136
136
``phpcr:class `` property to the right value.
137
137
138
- Now modify the existing service configuration for `` GenericInitializer `` as
139
- follows :
138
+ Now * remove * the old initializer service (`` acme_basiccms.basic_cms.phpcr.initializer ``) and
139
+ register your new site initializer :
140
140
141
141
.. configuration-block ::
142
142
@@ -188,8 +188,6 @@ Now empty your repository, reinitialize it and reload your fixtures:
188
188
189
189
.. code-block :: bash
190
190
191
- $ php app/console doctrine:phpcr:node:remove /cms
192
- $ php app/console doctrine:phpcr:repository:init
193
191
$ php app/console doctrine:phpcr:fixtures:load
194
192
195
193
and verify that the ``cms `` node has been created correctly, using the
@@ -219,6 +217,83 @@ and verify that the ``cms`` node has been created correctly, using the
219
217
with the right class. The drawback then is that there are two places where
220
218
initialization choices take place - do whatever you prefer.
221
219
220
+ Reconfigure the Admin Tree
221
+ --------------------------
222
+
223
+ If you look at your admin interface now, you will notice that the tree has
224
+ gone!
225
+
226
+ You need to tell the admin tree about the new ``Site `` document which is now
227
+ the root of your websites content tree:
228
+
229
+ .. configuration-block ::
230
+
231
+ .. code-block :: yaml
232
+
233
+ sonata_doctrine_phpcr_admin :
234
+ # ...
235
+ document_tree :
236
+ # ...
237
+ Acme\BasicCmsBundle\Document\Site :
238
+ valid_children :
239
+ - all
240
+
241
+ .. code-block :: xml
242
+
243
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
244
+ <container xmlns =" http://symfony.com/schema/dic/services" >
245
+
246
+ <config xmlns =" http://sonata-project.org/schema/dic/doctrine_phpcr_admin" />
247
+
248
+ <!-- ... -->
249
+
250
+ <document-tree class =" Acme\BasicCmsBundle\Document\Site" >
251
+ <valid-child >all</valid-child >
252
+ </document-tree >
253
+ </config >
254
+ </container >
255
+
256
+ .. code-block :: php
257
+
258
+ $container->loadFromExtension('sonata_doctrine_phpcr_admin', array(
259
+ // ...
260
+ 'document_tree' => array(
261
+ 'Acme\BasicCmsBundle\Document\Site' => array(
262
+ 'valid_children' => array(
263
+ 'all',
264
+ ),
265
+ ),
266
+ // ...
267
+ ));
268
+
269
+ If you check your admin interface you will see that the ``Site `` document is
270
+ now being displayed, however it has no children. You need to map the children on the
271
+ ``Site `` document, modify it as follows::
272
+
273
+ // src/Acme/BasicCmsBundle/Document/Site.php
274
+
275
+ // ...
276
+
277
+ /**
278
+ * @PHPCR\Document()
279
+ */
280
+ class Site
281
+ {
282
+ /**
283
+ * @PHPCR\Children()
284
+ */
285
+ protected $children;
286
+
287
+ // ...
288
+
289
+ public function getChildren()
290
+ {
291
+ return $this->children;
292
+ }
293
+ }
294
+
295
+ The tree should now again show your website structure.
296
+
222
297
Create the Make Homepage Button
223
298
-------------------------------
224
299
0 commit comments