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

Commit da43280

Browse files
authored
Merge pull request #773 from symfony-cmf/1.3
1.3 to master
2 parents 3651129 + 41b902a commit da43280

File tree

6 files changed

+124
-133
lines changed

6 files changed

+124
-133
lines changed

tutorial/auto-routing.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,31 +161,31 @@ You can now proceed to mapping your documents, create the following in your
161161

162162
.. code-block:: yaml
163163
164-
# src/Acme/BasicCmsBundle/Resources/config/cmf_routing_auto.yml
165-
Acme\BasicCmsBundle\Document\Page:
164+
# src/AppBundle/Resources/config/cmf_routing_auto.yml
165+
AppBundle\Document\Page:
166166
uri_schema: /page/{title}
167167
token_providers:
168168
title: [content_method, { method: getTitle }]
169169
170-
Acme\BasicCmsBundle\Document\Post:
170+
AppBundle\Document\Post:
171171
uri_schema: /post/{date}/{title}
172172
token_providers:
173173
date: [content_datetime, { method: getDate }]
174174
title: [content_method, { method: getTitle }]
175175
176176
.. code-block:: xml
177177
178-
<!-- src/Acme/BasicCmsBundle/Resources/config/cmf_routing_auto.xml -->
178+
<!-- src/AppBundle/Resources/config/cmf_routing_auto.xml -->
179179
<auto-mapping xmlns="http://cmf.symfony.com/schema/routing_auto">
180-
<mapping class="Acme\BasicCmsBundle\Document\Page"
180+
<mapping class="AppBundle\Document\Page"
181181
uri-schema="/page/{title}">
182182
183183
<token-provider token="title" name="content_method">
184184
<option name="method">getTitle</option>
185185
</token-provider>
186186
</mapping>
187187
188-
<mapping class="Acme\BasicCmsBundle\Document\Post"
188+
<mapping class="AppBundle\Document\Post"
189189
uri-schema="/post/{date}/{title}">
190190
191191
<token-provider token="date" name="content_datetime">

tutorial/content-to-controllers.rst

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ implementing the ``RoutesReferrersReadInterface``. This interface enables the ro
99
to retrieve routes which refer to the object implementing this interface, and this enables
1010
the system to generate a URL (for example when you use ``{{ path(mydocument) }}`` in Twig).
1111

12-
Earlier you did not have the RoutingBundle installed, so you could not add the mapping.
12+
Earlier you did not have the RoutingBundle installed, so you could not add the mapping.
1313

1414
Map the ``$routes`` property to contain a collection of all the routes which refer to this
1515
document::
1616

17-
// src/AcmeBundle/BasicCmsBundle/Document/ContentTrait.php
17+
// src/AppBundle/Document/ContentTrait.php
1818

1919
// ...
2020
trait ContentTrait
@@ -30,7 +30,7 @@ document::
3030
protected $routes;
3131

3232
// ...
33-
}
33+
}
3434

3535
And clear your cache:
3636

@@ -60,7 +60,7 @@ You can map a default controller for all instances of ``Page``:
6060
dynamic:
6161
# ...
6262
controllers_by_class:
63-
Acme\BasicCmsBundle\Document\Page: Acme\BasicCmsBundle\Controller\DefaultController::pageAction
63+
AppBundle\Document\Page: AppBundle\Controller\DefaultController::pageAction
6464
6565
.. code-block:: xml
6666
@@ -74,9 +74,9 @@ You can map a default controller for all instances of ``Page``:
7474
<dynamic generic-controller="cmf_content.controller:indexAction">
7575
<!-- ... -->
7676
<controllers-by-class
77-
class="Acme\BasicCmsBundle\Document\Page"
77+
class="AppBundle\Document\Page"
7878
>
79-
Acme\BasicCmsBundle\Controller\DefaultController::pageAction
79+
AppBundle\Controller\DefaultController::pageAction
8080
</controllers-by-class>
8181
</dynamic>
8282
</config>
@@ -89,20 +89,20 @@ You can map a default controller for all instances of ``Page``:
8989
'dynamic' => array(
9090
// ...
9191
'controllers_by_class' => array(
92-
'Acme\BasicCmsBundle\Document\Page' => 'Acme\BasicCmsBundle\Controller\DefaultController::pageAction',
92+
'AppBundle\Document\Page' => 'AppBundle\Controller\DefaultController::pageAction',
9393
),
9494
),
9595
));
9696
9797
This will cause requests to be forwarded to this controller when the route
9898
which matches the incoming request is provided by the dynamic router **and**
9999
the content document that that route references is of class
100-
``Acme\BasicCmsBundle\Document\Page``.
100+
``AppBundle\Document\Page``.
101101

102102
Now create the action in the default controller - you can pass the ``Page``
103103
object and all the ``Posts`` to the view::
104104

105-
// src/Acme/BasicCmsBundle/Controller/DefaultController.php
105+
// src/AppBundle/Controller/DefaultController.php
106106

107107
// ...
108108
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
@@ -117,7 +117,7 @@ object and all the ``Posts`` to the view::
117117
public function pageAction($contentDocument)
118118
{
119119
$dm = $this->get('doctrine_phpcr')->getManager();
120-
$posts = $dm->getRepository('AcmeBasicCmsBundle:Post')->findAll();
120+
$posts = $dm->getRepository('AppBundle:Post')->findAll();
121121

122122
return array(
123123
'page' => $contentDocument,
@@ -135,7 +135,7 @@ Add a corresponding template (note that this works because you use the
135135

136136
.. code-block:: html+jinja
137137

138-
{# src/Acme/BasicCmsBundle/Resources/views/Default/page.html.twig #}
138+
{# src/AppBundle/Resources/views/Default/page.html.twig #}
139139
<h1>{{ page.title }}</h1>
140140
<p>{{ page.content|raw }}</p>
141141
<h2>Our Blog Posts</h2>
@@ -147,7 +147,7 @@ Add a corresponding template (note that this works because you use the
147147

148148
.. code-block:: html+php
149149

150-
<!-- src/Acme/BasicCmsBundle/Resources/views/Default/page.html.twig -->
150+
<!-- src/AppBundle/Resources/views/Default/page.html.twig -->
151151
<h1><?php echo $page->getTitle() ?></h1>
152152
<p><?php echo $page->getContent() ?></p>
153153
<h2>Our Blog Posts</h2>

tutorial/getting-started.rst

Lines changed: 28 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,16 @@ Each part of the tutorial will detail the packages that it requires (if any) in
2323
section titled "installation".
2424

2525
If you intend to complete the entire tutorial you can save some time by adding
26-
all of the required packages now.
26+
all of the required packages now:
2727

28-
.. code-block:: javascript
29-
30-
{
31-
...
32-
require: {
33-
...
34-
"symfony-cmf/routing-auto-bundle": "~1.0",
35-
"symfony-cmf/menu-bundle": "~2.0",
36-
"sonata-project/doctrine-phpcr-admin-bundle": "~1.2",
37-
"symfony-cmf/tree-browser-bundle": "~1.1",
38-
"doctrine/data-fixtures": "~1.0",
39-
"symfony-cmf/routing-bundle": "~1.3",
40-
"symfony-cmf/routing": "~1.3"
41-
},
42-
...
43-
}
28+
.. code-block:: bash
4429
45-
Note that each time you modify your ``composer.json`` file you are required to
46-
run ``composer update``.
30+
$ composer require symfony-cmf/routing-auto-bundle \
31+
symfony-cmf/menu-bundle \
32+
sonata-project/doctrine-phpcr-admin-bundle \
33+
symfony-cmf/tree-browser-bundle \
34+
doctrine/data-fixtures \
35+
symfony-cmf/routing-bundle
4736
4837
Initialize the Database
4938
~~~~~~~~~~~~~~~~~~~~~~~
@@ -80,7 +69,7 @@ Now you can generate the bundle in which you will write most of your code:
8069

8170
.. code-block:: bash
8271
83-
$ php app/console generate:bundle --namespace=Acme/BasicCmsBundle --dir=src --format=yml --no-interaction
72+
$ php app/console generate:bundle --namespace=AppBundle --dir=src --format=yml --no-interaction
8473
8574
The Documents
8675
.............
@@ -89,8 +78,8 @@ You will create two document classes, one for the pages and one for the posts.
8978
These two documents share much of the same logic, so you create a ``trait``
9079
to reduce code duplication::
9180

92-
// src/Acme/BasicCmsBundle/Document/ContentTrait.php
93-
namespace Acme\BasicCmsBundle\Document;
81+
// src/AppBundle/Document/ContentTrait.php
82+
namespace AppBundle\Document;
9483

9584
use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCR;
9685

@@ -168,8 +157,8 @@ to reduce code duplication::
168157

169158
The ``Page`` class is therefore nice and simple::
170159

171-
// src/Acme/BasicCmsBundle/Document/Page.php
172-
namespace Acme\BasicCmsBundle\Document;
160+
// src/AppBundle/Document/Page.php
161+
namespace AppBundle\Document;
173162

174163
use Symfony\Cmf\Component\Routing\RouteReferrersReadInterface;
175164

@@ -188,8 +177,8 @@ other documents to hold a reference to the page. The ``Post`` class will also
188177
be referenceable and in addition will automatically set the date using the
189178
`pre persist lifecycle event`_ if it has not been explicitly set previously::
190179

191-
// src/Acme/BasicCmsBundle/Document/Post.php
192-
namespace Acme\BasicCmsBundle\Document;
180+
// src/AppBundle/Document/Post.php
181+
namespace AppBundle\Document;
193182

194183
use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCR;
195184
use Symfony\Cmf\Component\Routing\RouteReferrersReadInterface;
@@ -246,9 +235,9 @@ configuration:
246235

247236
.. code-block:: yaml
248237
249-
# src/Acme/BasicCmsBundle/Resources/config/services.yml
238+
# src/AppBundle/Resources/config/services.yml
250239
services:
251-
acme_basiccms.basic_cms.phpcr.initializer:
240+
app.phpcr.initializer:
252241
class: Doctrine\Bundle\PHPCRBundle\Initializer\GenericInitializer
253242
arguments:
254243
- My custom initializer
@@ -259,18 +248,18 @@ configuration:
259248
.. code-block:: xml
260249
261250
<?xml version="1.0" encoding="UTF-8" ?>
262-
<!-- src/Acme\BasicCmsBundle\Resources\services.xml -->
251+
<!-- src/AppBundle\Resources\services.xml -->
263252
<container xmlns="http://symfony.com/schema/dic/services"
264253
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
265-
xmlns:acme_demo="http://www.example.com/symfony/schema/"
254+
xmlns:app="http://www.example.com/symfony/schema/"
266255
xsi:schemaLocation="http://symfony.com/schema/dic/services
267256
http://symfony.com/schema/dic/services/services-1.0.xsd">
268257
269258
<!-- ... -->
270259
<services>
271260
<!-- ... -->
272261
273-
<service id="acme_basiccms.basic_cms.phpcr.initializer"
262+
<service id="app.phpcr.initializer"
274263
class="Doctrine\Bundle\PHPCRBundle\Initializer\GenericInitializer">
275264
276265
<argument>My custom initializer</argument>
@@ -288,10 +277,10 @@ configuration:
288277
289278
.. code-block:: php
290279
291-
// src/Acme/BasicCmsBundle/Resources/config/services.php
280+
// src/AppBundle/Resources/config/services.php
292281
$container
293282
->register(
294-
'acme_basiccms.basic_cms.phpcr.initializer',
283+
'app.phpcr.initializer',
295284
'Doctrine\Bundle\PHPCRBundle\Initializer\GenericInitializer'
296285
)
297286
->addArgument('My custom initializer')
@@ -349,10 +338,10 @@ Ensure that you have the following package installed:
349338
350339
Create a page for your CMS::
351340

352-
// src/Acme/BasicCmsBundle/DataFixtures/PHPCR/LoadPageData.php
353-
namespace Acme\BasicCmsBundle\DataFixtures\PHPCR;
341+
// src/AppBundle/DataFixtures/PHPCR/LoadPageData.php
342+
namespace AppBundle\DataFixtures\PHPCR;
354343

355-
use Acme\BasicCmsBundle\Document\Page;
344+
use AppBundle\Document\Page;
356345
use Doctrine\Common\DataFixtures\FixtureInterface;
357346
use Doctrine\Common\Persistence\ObjectManager;
358347
use Doctrine\ODM\PHPCR\DocumentManager;
@@ -383,13 +372,13 @@ Create a page for your CMS::
383372

384373
and add some posts::
385374

386-
// src/Acme/BasicCmsBundle/DataFixtures/PHPCR/LoadPostData.php
387-
namespace Acme\BasicCmsBundle\DataFixtures\PHPCR;
375+
// src/AppBundle/DataFixtures/PHPCR/LoadPostData.php
376+
namespace AppBundle\DataFixtures\PHPCR;
388377

389378
use Doctrine\Common\DataFixtures\FixtureInterface;
390379
use Doctrine\Common\Persistence\ObjectManager;
391380
use Doctrine\ODM\PHPCR\DocumentManager;
392-
use Acme\BasicCmsBundle\Document\Post;
381+
use AppBundle\Document\Post;
393382

394383
class LoadPostData implements FixtureInterface
395384
{

0 commit comments

Comments
 (0)