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

Commit b214074

Browse files
committed
Various fixes for tutorial
1 parent 3ac840c commit b214074

File tree

3 files changed

+59
-7
lines changed

3 files changed

+59
-7
lines changed

tutorial/content-to-controllers.rst

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

114114
return array(
@@ -155,6 +155,10 @@ Add a corresponding Twig template (note that this works because you use the
155155

156156
Now have another look at: http://localhost:8000/page/home
157157

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

tutorial/make-homepage.rst

Lines changed: 52 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,55 @@ 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+
.. code-block:: yaml
230+
231+
Acme\BasicCmsBundle\Document\Site:
232+
valid_children:
233+
- all
234+
235+
If you check your admin interface you will see that the ``Site`` document is
236+
showing, however it has no children. You need to map the children on the
237+
``Site`` document, modify it as follows:
238+
239+
.. code-block:: php
240+
241+
<?php
242+
243+
// src/Acme/BasicCmsBundle/Document/Site.php
244+
245+
// ...
246+
247+
/**
248+
* @PHPCR\Document()
249+
*/
250+
class Site
251+
{
252+
// ...
253+
254+
/**
255+
* @PHPCR\Children()
256+
*/
257+
protected $children;
258+
259+
public function getChildren()
260+
{
261+
return $this->children;
262+
}
263+
264+
// ...
265+
}
266+
267+
The tree should now again show your website structure.
268+
222269
Create the Make Homepage Button
223270
-------------------------------
224271

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)