Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit 775d2ec

Browse files
dantleechwouterj
authored andcommitted
Various fixes for tutorial
1 parent 3f7274c commit 775d2ec

File tree

3 files changed

+87
-7
lines changed

3 files changed

+87
-7
lines changed

tutorial/content-to-controllers.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ object and all the ``Posts`` to the view::
110110
*/
111111
public function pageAction($contentDocument)
112112
{
113-
$dm = $this->get('doctrine_phpcr')->getManagerForClass('AcmeBasicCmsBundle:Post');
113+
$dm = $this->get('doctrine_phpcr')->getManager();
114114
$posts = $dm->getRepository('AcmeBasicCmsBundle:Post')->findAll();
115115

116116
return array(
@@ -157,6 +157,10 @@ Add a corresponding Twig template (note that this works because you use the
157157

158158
Now have another look at: http://localhost:8000/page/home
159159

160+
.. note::
161+
162+
If you get an error, try clearing the cache.
163+
160164
Notice what is happening with the post object and the ``path`` function - you
161165
pass the ``Post`` object and the ``path`` function will pass the object to the
162166
router and because it implements the ``RouteReferrersReadInterface`` the

tutorial/make-homepage.rst

Lines changed: 80 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ node::
103103

104104
public function init(ManagerRegistry $registry)
105105
{
106-
$dm = $registry->getManagerForClass('Acme\BasicCmsBundle\Document\Site');
106+
$dm = $registry->getManager();
107107
if ($dm->find(null, $this->basePath)) {
108108
return;
109109
}
@@ -135,8 +135,8 @@ node::
135135
documents in initializers. With 1.0, you would need to manually set the
136136
``phpcr:class`` property to the right value.
137137

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:
140140

141141
.. configuration-block::
142142

@@ -188,8 +188,6 @@ Now empty your repository, reinitialize it and reload your fixtures:
188188

189189
.. code-block:: bash
190190
191-
$ php app/console doctrine:phpcr:node:remove /cms
192-
$ php app/console doctrine:phpcr:repository:init
193191
$ php app/console doctrine:phpcr:fixtures:load
194192
195193
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
219217
with the right class. The drawback then is that there are two places where
220218
initialization choices take place - do whatever you prefer.
221219

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+
222297
Create the Make Homepage Button
223298
-------------------------------
224299

tutorial/the-frontend.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ to which you will add the existing ``Home`` page and an additional ``About`` pag
114114
{
115115
public function load(ObjectManager $dm)
116116
{
117-
// ...
117+
$parent = $dm->find(null, '/cms/pages');
118+
118119
$rootPage = new Page();
119120
$rootPage->setTitle('main');
120121
$rootPage->setParentDocument($parent);

0 commit comments

Comments
 (0)