@@ -35,7 +35,7 @@ as a menu item.
35
35
There exists a bundle called :doc: `../bundles/simple_cms/index ` which
36
36
provides a similar solution to the one proposed in this tutorial. It
37
37
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
39
39
and content into a single document, the routes will be managed
40
40
automatically and the native CMF ``DynamicRouter `` will be used.
41
41
@@ -45,36 +45,8 @@ Part 1 - Getting Started
45
45
Initializing the Project
46
46
~~~~~~~~~~~~~~~~~~~~~~~~
47
47
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.
78
50
79
51
Install Additional Bundles
80
52
..........................
@@ -316,7 +288,7 @@ service container configuration:
316
288
317
289
# src/Acme/BasicCmsBundle/Resources/config/services.yml
318
290
services :
319
- acme.basiccms .phpcr.initializer :
291
+ acme.basic_cms .phpcr.initializer :
320
292
class : Doctrine\Bundle\PHPCRBundle\Initializer\GenericInitializer
321
293
arguments : [ "/cms/pages", "/cms/posts", "/cms/routes" ]
322
294
tags :
@@ -336,7 +308,7 @@ service container configuration:
336
308
<services >
337
309
<!-- ... -->
338
310
339
- <service id =" acme.basiccms .phpcr.initializer"
311
+ <service id =" acme.basic_cms .phpcr.initializer"
340
312
class =" Doctrine\Bundle\PHPCRBundle\Initializer\GenericInitializer" >
341
313
342
314
<argument type =" collection" >
@@ -355,7 +327,7 @@ service container configuration:
355
327
// src/Acme/BasicCmsBundle/Resources/config/services.php
356
328
$container
357
329
->register(
358
- 'acme.basiccms .phpcr.initializer',
330
+ 'acme.basic_cms .phpcr.initializer',
359
331
'Doctrine\Bundle\PHPCRBundle\Initializer\GenericInitializer'
360
332
)
361
333
->addArgument(array('/cms/pages', '/cms/posts', '/cms/routes'))
@@ -475,6 +447,15 @@ new route will be linked back to the target content:
475
447
476
448
.. image :: ../_images/cookbook/basic-cms-objects.png
477
449
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
+
478
459
Enable the Dynamic Router
479
460
~~~~~~~~~~~~~~~~~~~~~~~~~
480
461
@@ -536,7 +517,7 @@ This will:
536
517
#. Cause the default Symfony router to be replaced by the chain router. The
537
518
chain router enables you to have multiple routers in your application. You
538
519
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
540
521
files). The number indicates the order of precedence - the router with the
541
522
lowest number will be called first.;
542
523
#. Configure the **dynamic ** router which you have added to the router chain.
@@ -634,10 +615,10 @@ Now you will need to include this configuration:
634
615
<!-- src/Acme/BasicCmsBUndle/Resources/config/config.yml -->
635
616
?xml version="1.0" encoding="UTF-8" ?>
636
617
<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" >
641
622
642
623
<import resource =" routing_auto.yml" />
643
624
</container >
@@ -717,7 +698,7 @@ Enable the Sonata related bundles to your kernel::
717
698
}
718
699
}
719
700
720
- and publish your assets (omit ``--symlink `` if you use Windows!):
701
+ and publish your assets (remove ``--symlink `` if you use Windows!):
721
702
722
703
.. code-block :: bash
723
704
@@ -764,7 +745,7 @@ Sonata requires the ``sonata_block`` bundle to be configured in your main config
764
745
),
765
746
));
766
747
767
- and it needs the following entries in your routing file:
748
+ and it requires the following entries in your routing file:
768
749
769
750
.. configuration-block ::
770
751
@@ -859,9 +840,10 @@ No translations? Uncomment the translator in the configuration file:
859
840
),
860
841
));
861
842
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:
865
847
866
848
.. configuration-block ::
867
849
@@ -907,8 +889,10 @@ this:
907
889
),
908
890
));
909
891
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.
912
896
913
897
Creating the Admin Classes
914
898
~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -992,7 +976,7 @@ container configuration:
992
976
993
977
# src/Acme/BasicCmsBundle/Resources/config/config.yml
994
978
services :
995
- acme.basiccms .admin.page :
979
+ acme.basic_cms .admin.page :
996
980
class : Acme\BasicCmsBundle\Admin\PageAdmin
997
981
arguments :
998
982
- ' '
@@ -1002,7 +986,7 @@ container configuration:
1002
986
- { name: sonata.admin, manager_type: doctrine_phpcr, group: 'Basic CMS', label: Page }
1003
987
calls :
1004
988
- [setRouteBuilder, ['@sonata.admin.route.path_info_slashes']]
1005
- acme.basiccms .admin.post :
989
+ acme.basic_cms .admin.post :
1006
990
class : Acme\BasicCmsBundle\Admin\PostAdmin
1007
991
arguments :
1008
992
- ' '
@@ -1025,7 +1009,7 @@ container configuration:
1025
1009
<!-- ... -->
1026
1010
<services >
1027
1011
<!-- ... -->
1028
- <service id =" acme.basiccms .admin.page"
1012
+ <service id =" acme.basic_cms .admin.page"
1029
1013
class =" Acme\BasicCmsBundle\Admin\PageAdmin" >
1030
1014
1031
1015
<call method =" setRouteBuilder" >
@@ -1043,7 +1027,7 @@ container configuration:
1043
1027
<argument >SonataAdminBundle:CRUD</argument >
1044
1028
</service >
1045
1029
1046
- <service id =" acme.basiccms .admin.post"
1030
+ <service id =" acme.basic_cms .admin.post"
1047
1031
class =" Acme\BasicCmsBundle\Admin\PostAdmin" >
1048
1032
1049
1033
<call method =" setRouteBuilder" >
@@ -1069,7 +1053,7 @@ container configuration:
1069
1053
use Symfony\Component\DependencyInjection\Reference;
1070
1054
// ...
1071
1055
1072
- $container->register('acme.basiccms .admin.page', 'Acme\BasicCmsBundle\Admin\PageAdmin')
1056
+ $container->register('acme.basic_cms .admin.page', 'Acme\BasicCmsBundle\Admin\PageAdmin')
1073
1057
->addArgument('')
1074
1058
->addArgument('Acme\BasicCmsBundle\Document\Page')
1075
1059
->addArgument('SonataAdminBundle:CRUD')
@@ -1082,7 +1066,7 @@ container configuration:
1082
1066
new Reference('sonata.admin.route.path_info_slashes'),
1083
1067
))
1084
1068
;
1085
- $container->register('acme.basiccms .admin.post', 'Acme\BasicCmsBundle\Admin\PostAdmin')
1069
+ $container->register('acme.basic_cms .admin.post', 'Acme\BasicCmsBundle\Admin\PostAdmin')
1086
1070
->addArgument('')
1087
1071
->addArgument('Acme\BasicCmsBundle\Document\Post')
1088
1072
->addArgument('SonataAdminBundle:CRUD')
@@ -1245,10 +1229,12 @@ KnpMenuBundle::
1245
1229
}
1246
1230
}
1247
1231
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.
1252
1238
1253
1239
The options are the options used by KnpMenu system when rendering the menu.
1254
1240
The menu URL is inferred from the ``content `` option (note that you added the
@@ -1334,7 +1320,7 @@ configuration:
1334
1320
1335
1321
# src/Acme/BasicCmsBundle/Resources/config/config.yml
1336
1322
services :
1337
- acme.basiccms .menu_provider :
1323
+ acme.basic_cms .menu_provider :
1338
1324
class : Symfony\Cmf\Bundle\MenuBundle\Provider\PhpcrMenuProvider
1339
1325
arguments :
1340
1326
- ' @cmf_menu.factory'
@@ -1357,7 +1343,7 @@ configuration:
1357
1343
<services >
1358
1344
<!-- ... -->
1359
1345
<service
1360
- id =" acme.basiccms .menu_provider"
1346
+ id =" acme.basic_cms .menu_provider"
1361
1347
class =" Symfony\Cmf\Bundle\MenuBundle\Provider\PhpcrMenuProvider" >
1362
1348
<argument type =" service" id =" cmf_menu.factory" />
1363
1349
<argument type =" service" id =" doctrine_phpcr" />
@@ -1376,7 +1362,7 @@ configuration:
1376
1362
1377
1363
$container
1378
1364
->register(
1379
- 'acme.basiccms .menu_provider',
1365
+ 'acme.basic_cms .menu_provider',
1380
1366
'Symfony\Cmf\Bundle\MenuBundle\Provider\PhpcrMenuProvider'
1381
1367
)
1382
1368
->addArgument(new Reference('cmf_menu.factory'))
@@ -1438,8 +1424,7 @@ Part 5 - The "/" Home Route
1438
1424
1439
1425
All of your content should now be available at various URLs but your homepage
1440
1426
(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.
1443
1428
1444
1429
In this section you will add a side menu to Sonata Admin which will make
1445
1430
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
1662
1647
$dm->persist($page);
1663
1648
$dm->flush();
1664
1649
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(
1666
1651
'id' => $page->getId()
1667
1652
)));
1668
1653
}
0 commit comments