Permalink
Browse files

adding doc on phpcr-odm bundle and lots of cleanup

  • Loading branch information...
1 parent bb8dabe commit 1fd2ef672d35d304344c2505609bc5617380142e @dbu dbu committed Oct 15, 2012
View
@@ -38,8 +38,10 @@ to do it? The reference is the right place to search.
reference/routing-extra
reference/routing
reference/search
+ reference/simple-cms
reference/tree
reference/tree-browser
+ reference/phpcr-odm
.. _`Document planning`: https://github.com/symfony-cmf/symfony-cmf/wiki/Documentation-Planning
.. _`CMF website`: http://cmf.symfony.com/get-involved
View
@@ -1,16 +1,17 @@
-SymfonyCmfBlockBundle
-=====================
-
-The `SymfonyCmfBlockBundle <https://github.com/symfony-cmf/BlockBundle#readme>`_ provides integration with SonataBlockBundle.
-
-.. index:: BlockBundle
-
-Dependencies
-------------
-
-* `SonataBlockBundle <https://github.com/sonata-project/SonataBlockBundle#readme>`_
-
-Configuration
--------------
-
-The configuration key for this bundle is ``symfony_cmf_block``
+SymfonyCmfBlockBundle
+=====================
+
+The `SymfonyCmfBlockBundle <https://github.com/symfony-cmf/BlockBundle#readme>`_ provides integration with SonataBlockBundle.
+
+.. index:: BlockBundle
+
+Dependencies
+------------
+
+This bundle is based on the `SonataBlockBundle <https://github.com/sonata-project/SonataBlockBundle#readme>`_
+
+
+Configuration
+-------------
+
+The configuration key for this bundle is ``symfony_cmf_block``
View
@@ -105,10 +105,9 @@ image location.
Configuration
-------------
-Add the settings to the ``app/config/config.yml``:
-
.. code-block:: yaml
+ # app/config/config.yml
symfony_cmf_create:
# metadata loading
@@ -160,7 +159,7 @@ default IS_AUTHENTICATED_ANONYMOUSLY to the bundle.
If you specify a different role, create.js will only be loaded if the user has that role
and the REST handler (and image handler if enabled) will check the role.
-If you need more fine grained access control, look into the mapper `isEditable` method.
+If you need more fine grained access control, look into the mapper ``isEditable`` method.
You can extend the mapper you use and overwrite isEditable to answer whether the
passed domain object is editable.
@@ -230,14 +229,14 @@ Usage
Adjust your template to load the editor js files if the current session is allowed to edit content.
-::
+.. code-block:: jinja
{% render "symfony_cmf_create.jsloader.controller:includeJSFilesAction" %}
Plus make sure that assetic is rewriting paths in your css files, then include
the base css files (and customize with your css as needed) with
-::
+.. code-block:: jinja
{% include "SymfonyCmfCreateBundle::includecssfiles.html.twig" %}
@@ -254,15 +253,15 @@ For an example mapping see the files in the cmf-sandbox. Reference documentation
To render your model, use the createphp twig tag:
-.. code-block:: html
+.. code-block:: html+jinja
{% createphp page as="rdf" %}
{{ rdf|raw }}
{% endcreatephp %}
Or if you need more control over the generated HTML:
-.. code-block:: html
+.. code-block:: html+jinja
{% createphp page as="rdf" %}
<div {{ createphp_attributes(rdf) }}>
@@ -280,6 +279,8 @@ version of hallo that is bundled with create is used. To develop the actual code
you will need to checkout the full hallo repository first. You can do this by running
the following commenad from the command line:
+.. code-block:: bash
+
app/console cmf:create:init-hallo-devel
Then, set the ``symfony_cmf_create > use_coffee`` option to true in config.yml. This tells the
@@ -289,19 +290,21 @@ javascript from ``Resources/public/vendor/create/deps/hallo-min.js``.
This also means that you need to add a mapping for coffeescript in your assetic
configuration and you need the `coffee compiler set up correctly <http://coffeescript.org/#installation>`_.
-.. code-block:: yaml
+.. configuration-block::
- assetic:
- filters:
- cssrewrite: ~
- coffee:
- bin: %coffee.bin%
- node: %coffee.node%
- apply_to: %coffee.extension%
+ .. code-block:: yaml
- symfony_cmf_create:
- # set this to true if you want to develop hallo and edit the coffee files
- use_coffee: true|false
+ assetic:
+ filters:
+ cssrewrite: ~
+ coffee:
+ bin: %coffee.bin%
+ node: %coffee.node%
+ apply_to: %coffee.extension%
+
+ symfony_cmf_create:
+ # set this to true if you want to develop hallo and edit the coffee files
+ use_coffee: true|false
In the cmf sandbox we did a little hack to not trigger coffee script compiling.
In config.yml we make the coffee extension configurable. Now if the
@@ -312,8 +315,10 @@ installed.
The default values for the three parameters are::
-.. code-block:: yaml
+.. configuration-block::
+
+ .. code-block:: yaml
- coffee.bin: /usr/local/bin/coffee
- coffee.node: /usr/local/bin/node
- coffee.extension: \.coffee
+ coffee.bin: /usr/local/bin/coffee
+ coffee.node: /usr/local/bin/node
+ coffee.extension: \.coffee
View
@@ -1,104 +1,117 @@
-SymfonyCmfMenuBundle
-====================
-
-The `SymfonyCmfMenuBundle <https://github.com/symfony-cmf/MenuBundle#readme>`_
-provides menus from a doctrine object manager with the help of KnpMenuBundle.
-
-.. index:: MenuBundle
-
-Menu entries
-------------
-
-Document\MenuItem defines menu entries. You can build menu items based on
-symfony routes, absolute or relative urls or referenceable phpcr-odm content
-documents.
-
-The menu tree is built from documents under [menu_basepath]/[menuname]. To
-prevent accidentally exposing nodes, only nodes ending on -item are considered
-menu items.
-You can use different document classes for menu items, as long as they implement
-Knp\Menu\NodeInterface to integrate with KnpMenuBundle.
-
-The currently highlighted entry is determined by checking if the content
-associated with a menu document is the same as the content DoctrineRouter
-has put into the request.
-
-Until we have a decent tutorial, you can look into the `cmf-sandbox <https://github.com/symfony-cmf/cmf-sandbox>`_
-and specifically the `menu fixtures <https://github.com/symfony-cmf/cmf-sandbox/blob/master/src/Sandbox/MainBundle/Resources/data/fixtures/030_LoadMenuData.php>`_.
-
-The `CMF website <http://cmf.symfony.com>`_ is another application using the CMF and the MenuBundle.
-
-Configuration
--------------
-::
-
- knp_menu:
- twig: true
-
- symfony_cmf_menu:
- menu_basepath: /phpcr/path/to/menutree
- document_manager: doctrine_phpcr.odm.default_document_manager
- menu_document_class: null
- content_url_generator: symfony_cmf_routing_extra.dynamic_router
- content_key: null (resolves to DoctrineRouter::CONTENT_KEY)
- route_name: null
- use_sonata_admin: auto|true|false
- content_basepath: /phpcr/path/to/content (used for the menu admin)
-
-If ``sonata-project/doctrine-phpcr-admin-bundle`` is added to the composer require,
-the MenuBundle can be used inside the SonataDoctrinePhpcrAdminBundle. But then,
-the SonataDoctrinePhpcrAdminBundle has to be instantiated in your application's kernel.
-
-By default, ``use_sonata_admin`` is automatically set based on whether
-SonataDoctrinePhpcrAdminBundle is available.
-
-Usage
------
-
-Adjust your twig template to load the menu.
-
- {{ knp_menu_render('simple') }}
-
-
-The menu name is the name of the node under ``menu_basepath``. For example if your
-repository stores the menu nodes under ``/cms/menu`` , rendering "main" would mean
-to render the menu that is at ``/cms/menu/main``
-
-
-How to use non-default other components
----------------------------------------
-
-If you use the cmf menu with phpcr-odm, you just need to store Route documents
-unter ``menu_basepath``. If you use a different object manager, you need to
-make sure that the route root document is found with
-
- $dm->find(route_document_class, menu_basepath . menu_name)
-
-The route document must implement ``Knp\Menu\NodeInterface`` - see
-Document/MenuItem.php for an example. You probably need to specify
-menu_document_class too, as only phpcr-odm can determine the document from the
-database content.
-
-If you use the cmf menu with the DoctrineRouter, you need no route name as the
-menu document just needs to provide a field content_key in the options.
-If you want to use a different service to generate URLs, you need to make sure
-your menu entries provide information in your selected content_key that the url
-generator can use to generate the url. Depending on your generator, you might
-need to specify a route_name too.
-Note that if you just want to generate normal symfony routes with a menu that
-is in the database, you can pass the core router service as content_url_generator,
-make sure the content_key never matches and make your menu documents provide
-the route name and eventual routeParameters.
-
-
-Dependencies
-------------
-
-* KnpMenuBundle
-
-Unless you change defaults and provide your own implementations, also depends on
-
-* SymfonyRoutingExtraBundle for the doctrine router service symfony_cmf_chain_routing.doctrine_router
- Note that you need to explicitly enable the doctrine router as per default it is not loaded.
- See the documentation of the routing extra bundle for how to do this.
-* Doctrine PHPCR-ODM to load route documents from the content repository
+SymfonyCmfMenuBundle
+====================
+
+The `SymfonyCmfMenuBundle <https://github.com/symfony-cmf/MenuBundle#readme>`_
+provides menus from a doctrine object manager with the help of KnpMenuBundle.
+
+.. index:: MenuBundle
+
+
+Menu entries
+------------
+
+Document\MenuItem defines menu entries. You can build menu items based on
+symfony routes, absolute or relative urls or referenceable phpcr-odm content
+documents.
+
+The menu tree is built from documents under [menu_basepath]/[menuname]. You can
+use different document classes for menu items, as long as they implement
+``Knp\Menu\NodeInterface`` to integrate with KnpMenuBundle. The default MenuItem
+Document discards children that do not implement this interface.
+
+The currently highlighted entry is determined by checking if the content
+associated with a menu document is the same as the content the DynamicRouter
+has put into the request.
+
+Setup
+-----
+
+See `/tutorials/installing-configuring-cmf`.
+
+Configuration
+-------------
+
+If you want to use default configurations, you do not need to change anything.
+The values are:
+
+.. configuration-block::
+
+ .. code-block:: yaml
+
+ symfony_cmf_menu:
+ menu_basepath: /cms/menu
+ document_manager: default
+ menu_document_class: ~ # autodetected from stored content
+ content_url_generator: router
+ content_key: ~ # (resolves to DynamicRouter::CONTENT_KEY)
+ route_name: ~ # cmf routes are created by content instead of name
+ use_sonata_admin: auto # use true/false to force using / not using sonata admin
+ content_basepath: ~ # defaults to symfony_cmf_core.content_basepath
+
+If you want to render the menu from twig, make sure you have not disabled twig
+in the ``knp_menu`` configuration section.
+
+If ``sonata-project/doctrine-phpcr-admin-bundle`` is added to the composer.json
+require section, the MenuBundle can be used inside the SonataDoctrinePhpcrAdminBundle.
+Don't forget to instantiate ``SonataDoctrinePhpcrAdminBundle`` in your kernel in
+this case.
+
+By default, ``use_sonata_admin`` is automatically set based on whether
+SonataDoctrinePhpcrAdminBundle is available but you can explicitly disable it
+to not have it even if sonata is enabled, or explicitly enable to get an error
+if sonata becomes unavailable.
+
+
+Usage
+-----
+
+Adjust your twig template to load the menu.
+
+.. code-block:: jinja
+
+ {{ knp_menu_render('simple') }}
+
+The menu name is the name of the node under ``menu_basepath``. For example if your
+repository stores the menu nodes under ``/cms/menu`` , rendering "main" would mean
+to render the menu that is at ``/cms/menu/main``
+
+
+How to use non-default other components
+---------------------------------------
+
+If you use the cmf menu with phpcr-odm, you just need to store Route documents
+untdr ``menu_basepath``. If you use a different object manager, you need to
+make sure that the menu root document is found with
+
+.. code-block:: php
+
+ $dm->find($menu_document_class, $menu_basepath . $menu_name)
+
+The route document must implement ``Knp\Menu\NodeInterface`` - see
+Document/MenuItem.php for an example. You probably need to specify
+menu_document_class too, as only phpcr-odm can determine the document from the
+database content.
+
+If you use the cmf menu with the DynamicRouter, you need no route name as the
+menu document just needs to provide a field content_key in the options.
+If you want to use a different service to generate URLs, you need to make sure
+your menu entries provide information in your selected content_key that the url
+generator can use to generate the url. Depending on your generator, you might
+need to specify a route_name too.
+Note that if you just want to generate normal symfony routes with a menu that
+is in the database, you can pass the core router service as content_url_generator,
+make sure the content_key never matches and make your menu documents provide
+the route name and eventual routeParameters.
+
+
+Dependencies
+------------
+
+This bundle is extending the `KnpMenuBundle <https://github.com/knplabs/KnpMenuBundle>`_.
+
+Unless you change defaults and provide your own implementations, this bundle also depends on
+
+* ``SymfonyRoutingExtraBundle`` for the router service ``symfony_cmf_routing_extra.dynamic_router``.
+ Note that you need to explicitly enable the dynamic router as per default it is not loaded.
+ See the :doc:`documentation of the routing extra bundle</reference/routing-extra>` for how to do this.
+* :doc:`/reference/phpcr-odm` to load route documents from the content repository
Oops, something went wrong.

1 comment on commit 1fd2ef6

Owner

dbu commented on 1fd2ef6 Oct 15, 2012

oh wow, line ending fixes makes this look bigger than it actually was.

Please sign in to comment.