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

Commit d46f9a2

Browse files
committed
More code fixes and another grammer pass.
1 parent 28172f0 commit d46f9a2

File tree

4 files changed

+53
-65
lines changed

4 files changed

+53
-65
lines changed

cookbook/create_basic_cms_auto_routing.rst

Lines changed: 47 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ as a menu item.
3535
There exists a bundle called :doc:`../bundles/simple_cms/index` which
3636
provides a similar solution to the one proposed in this tutorial. It
3737
combines the route, menu and content into a single document and uses a
38-
custom router. This approach differs in that it will combine only the menu
38+
custom router. The approach taken in this tutorial will combine only the menu
3939
and content into a single document, the routes will be managed
4040
automatically and the native CMF ``DynamicRouter`` will be used.
4141

@@ -45,36 +45,8 @@ Part 1 - Getting Started
4545
Initializing the Project
4646
~~~~~~~~~~~~~~~~~~~~~~~~
4747

48-
Create a New Project
49-
....................
50-
51-
Get started by installing the following PHPCR ODM based Symfony distribution:
52-
53-
.. code-block:: bash
54-
55-
$ composer create-project --stablitiy=dev dantleech/symfony-doctrine-phpcr-edition basic-cms
56-
57-
.. note::
58-
59-
The `PHPCR-ODM Symfony distribution`_ above is the same as the `Symfony
60-
Standard Edition`_ except that the Doctrine ORM is replaced by the
61-
PHPCR-ODM.
62-
63-
PHP 5.4 features an in-built web server. You can use this throughout the
64-
tutorial, run it as follows:
65-
66-
.. code-block:: bash
67-
68-
$ php app/console server:run
69-
70-
and go to http://localhost:8000 to verify that everything is working.
71-
72-
.. note::
73-
74-
You could also use the `Symfony CMF Standard Edition`_. The CMF Standard
75-
Edition is also based on the Symfony Standard Edition and replaces the ORM
76-
with the PHPCR-ODM, however it also includes the entire CMF stack and some
77-
other dependencies which are not required for this tutorial.
48+
First, follow the generic steps in :doc:`create_new_project_phpcr_odm` to create a new project using
49+
the PHPCR-ODM.
7850

7951
Install Additional Bundles
8052
..........................
@@ -316,7 +288,7 @@ service container configuration:
316288
317289
# src/Acme/BasicCmsBundle/Resources/config/services.yml
318290
services:
319-
acme.basiccms.phpcr.initializer:
291+
acme.basic_cms.phpcr.initializer:
320292
class: Doctrine\Bundle\PHPCRBundle\Initializer\GenericInitializer
321293
arguments: [ "/cms/pages", "/cms/posts", "/cms/routes" ]
322294
tags:
@@ -336,7 +308,7 @@ service container configuration:
336308
<services>
337309
<!-- ... -->
338310
339-
<service id="acme.basiccms.phpcr.initializer"
311+
<service id="acme.basic_cms.phpcr.initializer"
340312
class="Doctrine\Bundle\PHPCRBundle\Initializer\GenericInitializer">
341313
342314
<argument type="collection">
@@ -355,7 +327,7 @@ service container configuration:
355327
// src/Acme/BasicCmsBundle/Resources/config/services.php
356328
$container
357329
->register(
358-
'acme.basiccms.phpcr.initializer',
330+
'acme.basic_cms.phpcr.initializer',
359331
'Doctrine\Bundle\PHPCRBundle\Initializer\GenericInitializer'
360332
)
361333
->addArgument(array('/cms/pages', '/cms/posts', '/cms/routes'))
@@ -475,6 +447,15 @@ new route will be linked back to the target content:
475447

476448
.. image:: ../_images/cookbook/basic-cms-objects.png
477449

450+
The paths above represent the path in the PHPCR-ODM document tree. In the next
451+
section you will define ``/cms/routes`` as the base path for routes, and subsequently
452+
the contents will be avilable at the following URLs:
453+
454+
* **Home**: ``http://localhost:8000/page/home``
455+
* **About**: ``http://localhost:8000/page/about``
456+
* etc.
457+
458+
478459
Enable the Dynamic Router
479460
~~~~~~~~~~~~~~~~~~~~~~~~~
480461

@@ -536,7 +517,7 @@ This will:
536517
#. Cause the default Symfony router to be replaced by the chain router. The
537518
chain router enables you to have multiple routers in your application. You
538519
add the dynamic router (which can retrieve routes from the database) and
539-
the default symfony router (which retrieves routes from configuration
520+
the default Symfony router (which retrieves routes from configuration
540521
files). The number indicates the order of precedence - the router with the
541522
lowest number will be called first.;
542523
#. Configure the **dynamic** router which you have added to the router chain.
@@ -634,10 +615,10 @@ Now you will need to include this configuration:
634615
<!-- src/Acme/BasicCmsBUndle/Resources/config/config.yml -->
635616
?xml version="1.0" encoding="UTF-8" ?>
636617
<container
637-
xmlns="http://symfony.com/schema/dic/services"
638-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
639-
xsi:schemaLocation="http://symfony.com/schema/dic/services
640-
http://symfony.com/schema/dic/services/services-1.0.xsd">
618+
xmlns="http://symfony.com/schema/dic/services"
619+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
620+
xsi:schemaLocation="http://symfony.com/schema/dic/services
621+
http://symfony.com/schema/dic/services/services-1.0.xsd">
641622
642623
<import resource="routing_auto.yml"/>
643624
</container>
@@ -717,7 +698,7 @@ Enable the Sonata related bundles to your kernel::
717698
}
718699
}
719700

720-
and publish your assets (omit ``--symlink`` if you use Windows!):
701+
and publish your assets (remove ``--symlink`` if you use Windows!):
721702

722703
.. code-block:: bash
723704
@@ -764,7 +745,7 @@ Sonata requires the ``sonata_block`` bundle to be configured in your main config
764745
),
765746
));
766747
767-
and it needs the following entries in your routing file:
748+
and it requires the following entries in your routing file:
768749

769750
.. configuration-block::
770751

@@ -859,9 +840,10 @@ No translations? Uncomment the translator in the configuration file:
859840
),
860841
));
861842
862-
Notice that adminstration class of the routing bundle has been automatically
863-
registered. Your routes will be managed automatically so you should disable
864-
this:
843+
Notice that the adminstration class of the RoutingBundle has been automatically
844+
registered. However, this interface is not required in your application as the routes
845+
are managed by the RoutingAutoBundle and not the administrator. You can disable
846+
the RoutingBundle admin as follows:
865847

866848
.. configuration-block::
867849

@@ -907,8 +889,10 @@ this:
907889
),
908890
));
909891
910-
All Sonata Admin aware CMF bundles have such a configuration option and it
911-
prevents the admin class (or classes) from being registered.
892+
.. note::
893+
894+
All Sonata Admin aware CMF bundles have such a configuration option and it
895+
prevents the admin class (or classes) from being registered.
912896

913897
Creating the Admin Classes
914898
~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -992,7 +976,7 @@ container configuration:
992976
993977
# src/Acme/BasicCmsBundle/Resources/config/config.yml
994978
services:
995-
acme.basiccms.admin.page:
979+
acme.basic_cms.admin.page:
996980
class: Acme\BasicCmsBundle\Admin\PageAdmin
997981
arguments:
998982
- ''
@@ -1002,7 +986,7 @@ container configuration:
1002986
- { name: sonata.admin, manager_type: doctrine_phpcr, group: 'Basic CMS', label: Page }
1003987
calls:
1004988
- [setRouteBuilder, ['@sonata.admin.route.path_info_slashes']]
1005-
acme.basiccms.admin.post:
989+
acme.basic_cms.admin.post:
1006990
class: Acme\BasicCmsBundle\Admin\PostAdmin
1007991
arguments:
1008992
- ''
@@ -1025,7 +1009,7 @@ container configuration:
10251009
<!-- ... -->
10261010
<services>
10271011
<!-- ... -->
1028-
<service id="acme.basiccms.admin.page"
1012+
<service id="acme.basic_cms.admin.page"
10291013
class="Acme\BasicCmsBundle\Admin\PageAdmin">
10301014
10311015
<call method="setRouteBuilder">
@@ -1043,7 +1027,7 @@ container configuration:
10431027
<argument>SonataAdminBundle:CRUD</argument>
10441028
</service>
10451029
1046-
<service id="acme.basiccms.admin.post"
1030+
<service id="acme.basic_cms.admin.post"
10471031
class="Acme\BasicCmsBundle\Admin\PostAdmin">
10481032
10491033
<call method="setRouteBuilder">
@@ -1069,7 +1053,7 @@ container configuration:
10691053
use Symfony\Component\DependencyInjection\Reference;
10701054
// ...
10711055
1072-
$container->register('acme.basiccms.admin.page', 'Acme\BasicCmsBundle\Admin\PageAdmin')
1056+
$container->register('acme.basic_cms.admin.page', 'Acme\BasicCmsBundle\Admin\PageAdmin')
10731057
->addArgument('')
10741058
->addArgument('Acme\BasicCmsBundle\Document\Page')
10751059
->addArgument('SonataAdminBundle:CRUD')
@@ -1082,7 +1066,7 @@ container configuration:
10821066
new Reference('sonata.admin.route.path_info_slashes'),
10831067
))
10841068
;
1085-
$container->register('acme.basiccms.admin.post', 'Acme\BasicCmsBundle\Admin\PostAdmin')
1069+
$container->register('acme.basic_cms.admin.post', 'Acme\BasicCmsBundle\Admin\PostAdmin')
10861070
->addArgument('')
10871071
->addArgument('Acme\BasicCmsBundle\Document\Post')
10881072
->addArgument('SonataAdminBundle:CRUD')
@@ -1245,10 +1229,12 @@ KnpMenuBundle::
12451229
}
12461230
}
12471231

1248-
Menus are hierarchical, PHPCR-ODM is also hierarchical. Here you add an
1249-
additional mapping, ``@Children``, which will cause PHPCR-ODM to populate the
1250-
annotated property instance ``$children`` with the child documents of this
1251-
document.
1232+
Menus are hierarchical, PHPCR-ODM is also hierarchical and so lends itself
1233+
well to this use case.
1234+
1235+
Here you add an additional mapping, ``@Children``, which will cause PHPCR-ODM
1236+
to populate the annotated property instance ``$children`` with the child
1237+
documents of this document.
12521238

12531239
The options are the options used by KnpMenu system when rendering the menu.
12541240
The menu URL is inferred from the ``content`` option (note that you added the
@@ -1334,7 +1320,7 @@ configuration:
13341320
13351321
# src/Acme/BasicCmsBundle/Resources/config/config.yml
13361322
services:
1337-
acme.basiccms.menu_provider:
1323+
acme.basic_cms.menu_provider:
13381324
class: Symfony\Cmf\Bundle\MenuBundle\Provider\PhpcrMenuProvider
13391325
arguments:
13401326
- '@cmf_menu.factory'
@@ -1357,7 +1343,7 @@ configuration:
13571343
<services>
13581344
<!-- ... -->
13591345
<service
1360-
id="acme.basiccms.menu_provider"
1346+
id="acme.basic_cms.menu_provider"
13611347
class="Symfony\Cmf\Bundle\MenuBundle\Provider\PhpcrMenuProvider">
13621348
<argument type="service" id="cmf_menu.factory"/>
13631349
<argument type="service" id="doctrine_phpcr"/>
@@ -1376,7 +1362,7 @@ configuration:
13761362
13771363
$container
13781364
->register(
1379-
'acme.basiccms.menu_provider',
1365+
'acme.basic_cms.menu_provider',
13801366
'Symfony\Cmf\Bundle\MenuBundle\Provider\PhpcrMenuProvider'
13811367
)
13821368
->addArgument(new Reference('cmf_menu.factory'))
@@ -1438,8 +1424,7 @@ Part 5 - The "/" Home Route
14381424

14391425
All of your content should now be available at various URLs but your homepage
14401426
(http://localhost:8000) still shows the default Symfony Standard Edition
1441-
page. You need to add a mechanism to enable the administrator to specify a
1442-
default page for your CMS.
1427+
index page.
14431428

14441429
In this section you will add a side menu to Sonata Admin which will make
14451430
enable the user to make a specified page act as the homepage of your CMS.
@@ -1662,7 +1647,7 @@ making a given page the homepage. Add the following to the existing
16621647
$dm->persist($page);
16631648
$dm->flush();
16641649

1665-
return $this->redirect($this->generateUrl('admin_acme_basiccms_page_edit', array(
1650+
return $this->redirect($this->generateUrl('admin_acme_basic_cms_page_edit', array(
16661651
'id' => $page->getId()
16671652
)));
16681653
}

cookbook/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ The Cookbook
55
:hidden:
66

77
create_new_project_phpcr_odm
8+
create_basic_cms_auto_routing
89
database/choosing_storage_layer
910
editions/cmf_sandbox
1011
editions/cmf_core

cookbook/map.rst.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* :doc:`editions/cmf_sandbox`
88
* :doc:`editions/cmf_core`
99
* :doc:`create_new_project_phpcr_odm`
10+
* :doc:`create_basic_cms_auto_routing`
1011
* :doc:`installing_configuring_doctrine_phpcr_odm`
1112
* :doc:`creating_cms_using_cmf_and_sonata`
1213
* :doc:`using_blockbundle_and_contentbundle`

index.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,14 @@ Want to know more about the CMF and how each part can be configured? There's a t
135135
:maxdepth: 1
136136

137137
cookbook/create_new_project_phpcr_odm
138+
cookbook/create_basic_cms_auto_routing
139+
cookbook/creating_cms_using_cmf_and_sonata
138140
cookbook/database/choosing_storage_layer
139-
cookbook/editions/cmf_sandbox
140141
cookbook/editions/cmf_core
142+
cookbook/editions/cmf_sandbox
143+
cookbook/handling_multilang_documents
141144
cookbook/installing_configuring_doctrine_phpcr_odm
142-
cookbook/creating_cms_using_cmf_and_sonata
143145
cookbook/using_blockbundle_and_contentbundle
144-
cookbook/handling_multilang_documents
145146

146147
Contributing
147148
------------

0 commit comments

Comments
 (0)