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

Commit a77877c

Browse files
committed
feature #595 [WIP] Tutorial Updates for 1.2 (dantleech)
This PR was submitted for the dev branch but it was merged into the master branch instead (closes #595). Discussion ---------- [WIP] Tutorial Updates for 1.2 Updates and improvements for 1.2. Note there is a problem in that the RoutingAutoBundle intializes before the initializer that we create in the last chapter, causing it to fail. We need to add support for initializer priority: doctrine/DoctrinePHPCRBundle#173 Commits ------- dc3de60 [WIP] Tutorial Updates for 1.2
2 parents 6102524 + dc3de60 commit a77877c

File tree

5 files changed

+48
-25
lines changed

5 files changed

+48
-25
lines changed

cookbook/database/create_new_project_phpcr_odm.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ content repository.
3636
...
3737
"require": {
3838
...
39-
"doctrine/phpcr-bundle": "1.2.*",
40-
"doctrine/phpcr-odm": "1.2.*",
41-
"jackalope/jackalope-doctrine-dbal": "1.2.*"
39+
"doctrine/phpcr-bundle": "~1.2",
40+
"doctrine/phpcr-odm": "~1.2",
41+
"jackalope/jackalope-doctrine-dbal": "~1.1,>=1.1.2"
4242
}
4343
}
4444

tutorial/content-to-controllers.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ document::
3232
// ...
3333
}
3434

35+
And clear your cache:
36+
37+
.. code-block:: bash
38+
39+
$ php app/console cache:clear
40+
3541
Now you can call the method ``getRoutes`` on either ``Page`` or ``Post`` and retrieve all the
3642
routes which refer to that document ... pretty cool!
3743

@@ -122,7 +128,7 @@ object and all the ``Posts`` to the view::
122128

123129
The ``Page`` object is passed automatically as ``$contentDocument``.
124130

125-
Add a corresponding Twig template (note that this works because you use the
131+
Add a corresponding template (note that this works because you use the
126132
``@Template`` annotation):
127133

128134
.. configuration-block::
@@ -157,10 +163,6 @@ Add a corresponding Twig template (note that this works because you use the
157163

158164
Now have another look at: http://localhost:8000/page/home
159165

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

tutorial/getting-started.rst

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,13 @@ file in the previous step.
4040
...
4141
require: {
4242
...
43-
"doctrine/phpcr-bundle": "1.1.*",
44-
"jackalope/jackalope-doctrine-dbal": "1.1.0",
45-
"symfony-cmf/routing-auto-bundle": "dev-master",
46-
"symfony-cmf/menu-bundle": "1.2.*",
47-
"sonata-project/doctrine-phpcr-admin-bundle": "1.1.*",
48-
"symfony-cmf/tree-browser-bundle": "1.1.x-dev as 1.0",
49-
"doctrine/data-fixtures": "1.0.*",
50-
"phpcr/phpcr-utils": "1.1.*",
51-
"symfony-cmf/routing-bundle": "1.2.*",
52-
"symfony-cmf/routing": "1.2.*"
43+
"symfony-cmf/routing-auto-bundle": "~1.0",
44+
"symfony-cmf/menu-bundle": "~1.2",
45+
"sonata-project/doctrine-phpcr-admin-bundle": "~1.2",
46+
"symfony-cmf/tree-browser-bundle": "~1.1",
47+
"doctrine/data-fixtures": "~1.0",
48+
"symfony-cmf/routing-bundle": "~1.3",
49+
"symfony-cmf/routing": "~1.3"
5350
},
5451
...
5552
}

tutorial/make-homepage.rst

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,11 @@ 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 *remove* the old initializer service (``acme_basiccms.basic_cms.phpcr.initializer``) and
139-
register your new site initializer:
138+
Now:
139+
140+
1. *Remove* the initializer service that you created in the
141+
:doc:`getting-started` chapter (``acme_basiccms.basic_cms.phpcr.initializer``).
142+
2. Register your new site initializer:
140143

141144
.. configuration-block::
142145

@@ -148,7 +151,7 @@ register your new site initializer:
148151
acme_basiccms.phpcr.initializer.site:
149152
class: Acme\BasicCmsBundle\Initializer\SiteInitializer
150153
tags:
151-
- { name: doctrine_phpcr.initializer }
154+
- { name: doctrine_phpcr.initializer, priority: 50 }
152155
153156
.. code-block:: xml
154157
@@ -165,7 +168,7 @@ register your new site initializer:
165168
<!-- ... -->
166169
<service id="acme_basiccms.phpcr.initializer.site"
167170
class="Acme\BasicCmsBundle\Initializer\SiteInitializer">
168-
<tag name="doctrine_phpcr.initializer"/>
171+
<tag name="doctrine_phpcr.initializer" priority="50"/>
169172
</service>
170173
</services>
171174
@@ -181,9 +184,16 @@ register your new site initializer:
181184
'acme_basiccms.phpcr.initializer.site',
182185
'Acme\BasicCmsBundle\Initializer\SiteInitializer'
183186
)
184-
->addTag('doctrine_phpcr.initializer', array('name' => 'doctrine_phpcr.initializer')
187+
->addTag('doctrine_phpcr.initializer', array('name' => 'doctrine_phpcr.initializer', 'priority' => 50)
185188
;
186189
190+
.. note::
191+
192+
You may have noticed that you have set the priority of the initializer.
193+
Initializers with high priorities will be called before initializers with
194+
lower priorities. Here it is necessary to increase the priority of your
195+
listener to prevent other initializers creating the `cms` node first.
196+
187197
Now empty your repository, reinitialize it and reload your fixtures:
188198

189199
.. code-block:: bash

tutorial/the-frontend.rst

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ dependency, :doc:`CoreBundle <../bundles/core/introduction>`, to your kernel::
2121
{
2222
$bundles = array(
2323
// ...
24-
new Knp\Bundle\MenuBundle\KnpMenuBundle(),
2524
new Symfony\Cmf\Bundle\CoreBundle\CmfCoreBundle(),
2625
new Symfony\Cmf\Bundle\MenuBundle\CmfMenuBundle(),
2726
);
@@ -30,11 +29,18 @@ dependency, :doc:`CoreBundle <../bundles/core/introduction>`, to your kernel::
3029
}
3130
}
3231

32+
.. note::
33+
34+
The KnpMenuBundle is also required but was already included in the
35+
:doc:`sonata-admin` chapter. If you skipped that chapter be sure to add
36+
this bundle now.
37+
3338
Modify the Page Document
3439
------------------------
3540

3641
The menu document has to implement the ``Knp\Menu\NodeInterface``
37-
provided by the KnpMenuBundle::
42+
provided by the KnpMenuBundle. Modify the Page document so that it
43+
implements the this interface::
3844

3945
// src/Acme/BasicCmsBundle/Document/Page.php
4046
namespace Acme\BasicCmsBundle\Document;
@@ -45,6 +51,14 @@ provided by the KnpMenuBundle::
4551
use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCR;
4652

4753
class Page implements RouteReferrersReadInterface, NodeInterface
54+
55+
Now add the following to the document to fulfil the contract::
56+
57+
// src/Acme/BasicCmsBundle/Document/Page.php
58+
59+
// ...
60+
61+
class Page implements RouteReferrersReadInterface, NodeInterface
4862
{
4963
// ...
5064

0 commit comments

Comments
 (0)