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

Commit ff3edee

Browse files
committed
[#414] Moved all 1.1 features to dev
1 parent f058ba8 commit ff3edee

File tree

10 files changed

+110
-71
lines changed

10 files changed

+110
-71
lines changed

book/routing.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ order of precedence):
248248

249249
* Explicit: The ``Route`` document itself can explicitly declare the target
250250
Controller if one is returned from ``getDefault('_controller')``.
251-
* By alias: The ``Route`` document returns a value from ``getDefault('type')``,
251+
* By type: The ``Route`` document returns a value from ``getDefault('type')``,
252252
which is then matched against the provided configuration from config.yml
253253
* By class: Requires the ``Route`` document to implement ``RouteObjectInterface``
254254
and return an object for ``getContent()``. The returned class type is
@@ -302,7 +302,7 @@ Here's an example of how to configure the above mentioned options:
302302
cmf_content.controller::indexAction
303303
</controllers-by-class>
304304
305-
<templates-by-class alias="Symfony\Cmf\Bundle\ContentBundle\Document\StaticContent"
305+
<templates-by-class class="Symfony\Cmf\Bundle\ContentBundle\Document\StaticContent"
306306
>
307307
CmfContentBundle:StaticContent:index.html.twig
308308
</templates-by-class>

bundles/create/introduction.rst

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,12 +281,30 @@ Access Control
281281

282282
In order to limit who can edit content, the provided controllers as well as the
283283
JavaScript loader check if the current user is granted the configured
284-
``cmf_create.role``. By default the role is ``ROLE_ADMIN``.
284+
``cmf_create.security.role``. By default the role is ``ROLE_ADMIN``.
285285

286286
.. tip::
287287

288288
In order to have security in place, you need to configure a
289289
"Symfony2 firewall". Read more in the `Symfony2 security chapter`_.
290+
If you do not do that, create.js will not be loaded and editing
291+
will be disabled.
292+
293+
If you do not want to edit on the production domain directly, e.g.
294+
because of caching, you can provide a second domain where you have
295+
security configured and do the editing there.
296+
297+
You can completely disable security checks by setting the role parameter to
298+
boolean ``false``. Then you need to configure access permissions on the routes
299+
defined in ``Resources/routing/rest.xml`` and, if activated, in ``image.xml``.
300+
If you set the role to false but do not configure any security,
301+
**every visitor of your site will be able to edit the content**.
302+
You also will need custom logic to decide whether to include the create.js
303+
JavaScript files.
304+
305+
You can also use a custom security check service by implementing
306+
``Symfony\Cmf\Bundle\CreateBundle\Security\AccessCheckerInterface``
307+
and setting this service in ``cmf_create.security.checker_service``.
290308

291309
If you need more fine grained access control, look into the CreatePHP
292310
``RdfMapperInterface`` ``isEditable`` method. You can extend a mapper and
@@ -296,9 +314,12 @@ editable.
296314
Load create.js JavaScript and CSS
297315
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
298316

299-
This bundle provides templates that load the required Javascript and CSS files
300-
based on Assetic. The Javascript loader also parametrizes the configuration
301-
for create.js and the chosen editor.
317+
This bundle provides a template that loads the required CSS files, as well as
318+
a controller action that loads the necessary JavaScript *if* the current user
319+
is allowed to edit according to
320+
:ref:`the security configuration <bundle_create_introduction_access_control>`.
321+
The JavaScript loader also parametrizes the configuration for create.js and
322+
WYSIWYG editor.
302323

303324
Alternatively, you can of course use your own templates to include the assets
304325
needed by create.js.
@@ -356,6 +377,12 @@ For Symfony 2.1, the syntax is:
356377
'_locale' => $app->getRequest()->getLocale(),
357378
) ?>
358379
380+
.. tip::
381+
382+
You can include this call unconditionally. The controller checks if the
383+
current user is allowed to edit and only in that case includes the
384+
JavaScript.
385+
359386
.. note::
360387

361388
The provided JavaScript file configures create.js and the editor. If you

bundles/phpcr_odm.rst

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,12 @@ and remove them on the fly.
606606
phpcr_odm_reference_collection
607607
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
608608

609+
.. caution::
610+
611+
This form type was deprecated in DoctrinePHPCRBundle 1.1 and will be
612+
removed in DoctrinePHPCRBundle 1.2. You should use the `phpcr_document`_
613+
type instead, which can do the same but better.
614+
609615
This form type handles editing ``ReferenceMany`` collections on PHPCR-ODM
610616
documents. It is a choice field with an added ``referenced_class`` required
611617
option that specifies the class of the referenced target document.
@@ -703,7 +709,16 @@ A service to use the generic initializer looks like this:
703709
$definition->addTag('doctrine_phpcr.initializer');
704710
$container->setDefinition('acme.phpcr.initializer', $definition);
705711
706-
The ``doctrine:phpcr:repository:init`` command runs all tagged initializers.
712+
You can execute your initializers using the following command:
713+
714+
.. code-block:: bash
715+
716+
$ php app/console doctrine:phpcr:repository:init
717+
718+
.. versionadded:: 1.1
719+
720+
Since DoctrinePHPCRBundle 1.1 the load data fixtures command will automatically
721+
execute the initializers after purging the database.
707722

708723
Fixture Loading
709724
---------------

cookbook/create_new_project_phpcr_odm.rst

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,7 @@ content repository.
6262
}
6363
}
6464

65-
**Step 5**: (*optional*) Register the PHPCR-ODM annotations in ``app/autoload.php``::
66-
67-
// app/autoload.php
68-
69-
// ...
70-
AnnotationRegistry::registerFile(
71-
__DIR__.'/../vendor/doctrine/phpcr-odm/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/DoctrineAnnotations.php'
72-
);
73-
74-
**Step 6**: Modify ``parameters.yml.dist``, adding the required PHPCR-ODM settings:
65+
**Step 5**: Modify ``parameters.yml.dist``, adding the required PHPCR-ODM settings:
7566

7667
.. code-block:: yaml
7768
@@ -142,7 +133,7 @@ content repository.
142133
),
143134
));
144135
145-
**Step 8**: Run ``composer update``:
136+
**Step 7**: Run ``composer update``:
146137

147138
.. code-block:: bash
148139

cookbook/creating_a_cms/getting-started.rst

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,9 @@ configuration:
313313
to understand these details right now. To learn more about PHPCR read
314314
:doc:`../database/choosing_storage_layer`.
315315

316-
Execute the ``doctrine:phpcr:repository:init`` command to initialize (or
317-
reinitialize) the repository:
316+
The initalizers will be executed automatically when you load your data
317+
fixtures (as detailed in the next section) or alternatively you can execute
318+
them manually using the following command:
318319

319320
.. code-block:: bash
320321
@@ -361,13 +362,11 @@ Create a page for your CMS::
361362
use Acme\BasicCmsBundle\Document\Page;
362363
use Doctrine\Common\DataFixtures\FixtureInterface;
363364
use Doctrine\Common\Persistence\ObjectManager;
364-
use PHPCR\Util\NodeHelper;
365365

366366
class LoadPageData implements FixtureInterface
367367
{
368368
public function load(ObjectManager $dm)
369369
{
370-
NodeHelper::createPath($dm->getPhpcrSession(), '/cms/pages');
371370
$parent = $dm->find(null, '/cms/pages');
372371

373372
$page = new Page();
@@ -391,14 +390,12 @@ and add some posts::
391390
use Doctrine\Common\DataFixtures\FixtureInterface;
392391
use Doctrine\Common\Persistence\ObjectManager;
393392
use Acme\BasicCmsBundle\Document\Post;
394-
use PHPCR\Util\NodeHelper;
395393

396394
class LoadPostData implements FixtureInterface
397395
{
398396
public function load(ObjectManager $dm)
399397
{
400398
$parent = $dm->find(null, '/cms/posts');
401-
NodeHelper::createPath($dm->getPhpcrSession(), '/cms/posts');
402399

403400
foreach (array('First', 'Second', 'Third', 'Forth') as $title) {
404401
$post = new Post();
@@ -424,15 +421,6 @@ and load the fixtures:
424421
425422
You should now have some data in your content repository.
426423

427-
.. note::
428-
429-
The classes above use ``NodeHelper::createPath`` to create the paths
430-
``/cms/posts`` and ``/cms/pages`` - this is exactly what the
431-
initializer did -- why do the classes do it again? This is a known issue - the
432-
data fixtures loader will purge the workspace and it will **not** call the
433-
initializer, so when using data fixtures it is currently necessary to manually
434-
create the paths.
435-
436424
.. _`routingautobundle documentation`: http://symfony.com/doc/current/cmf/bundles/routing_auto.html
437425
.. _`dynamicrouter to generate urls`: http://symfony.com/doc/current/cmf/bundles/routing/dynamic.html#url-generation-with-the-dynamicrouterA
438426
.. _`idempotent`: http://en.wiktionary.org/wiki/idempotent

cookbook/creating_a_cms/make-homepage.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,6 @@ and verify that the ``cms`` node has been updated by using the
195195
disadvantage then is that there are two places where initialization
196196
choices take place - do whatever you prefer.
197197

198-
As noted earlier, currently when data fixtures are loaded they will erase the
199-
workspace, including the paths created by the initializers. This means that
200-
each time you load your data fixtures you must also reinitialize the
201-
repository.
202-
203198
Create the Make Homepage Button
204199
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
205200

cookbook/editions/cmf_core.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ If you haven't done so already, make sure you have followed these steps from
9999

100100
* Initialize ``DoctrinePHPCRBundle`` in ``app/AppKernel.php``
101101
* Ensure there is a ``doctrine_phpcr:`` section in ``app/config/config.yml``
102-
* Add the ``AnnotationRegistry::registerFile`` line to ``app/autoload.php``
103102

104103
Configure the BlockBundle in your ``config.yml``:
105104

cookbook/installing_configuring_doctrine_phpcr_odm.rst

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -132,19 +132,6 @@ To install the above dependencies, run:
132132
133133
$ php composer.phar update
134134
135-
Register Annotations
136-
~~~~~~~~~~~~~~~~~~~~
137-
138-
PHPCR-ODM uses annotations and these need to be registered in your
139-
``app/autoload.php`` file. Add the following line, immediately after the last
140-
``AnnotationRegistry::registerFile`` line::
141-
142-
// app/autoload.php
143-
144-
// ...
145-
AnnotationRegistry::registerFile(__DIR__.'/../vendor/doctrine/phpcr-odm/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/DoctrineAnnotations.php');
146-
// ...
147-
148135
Initialize Bundles
149136
~~~~~~~~~~~~~~~~~~
150137

reference/configuration/create.rst

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,49 @@ Configuration
1818
Security
1919
~~~~~~~~
2020

21-
The controller that receives save requests from create.js requires the user to
22-
have a specific role to control who is allowed to edit content. As it would
21+
The controller that receives save requests from create.js does a security check
22+
to determine whether the current user is allowed to edit content. As it would
2323
not be convenient to show the create.js editor to users not allowed to edit the
24-
site, the controller loading the create.js javascripts with the
25-
``includeJSFilesAction`` also checks this role. If the image controller is
26-
activated, it checks for this role as well.
24+
site, the controller loading the create.js JavaScript files with the
25+
``includeJSFilesAction`` also uses the same security check, as does the image
26+
upload controller if it is activated.
27+
28+
The default security check checks if the user has a specified role. If nothing
29+
is configured, the default role is ``ROLE_ADMIN``. If you set the parameter to
30+
boolean ``false``, every user will be allowed to save changes through the REST
31+
controller.
32+
33+
A last option is to configure your own ``checker_service`` to be used instead
34+
of the role based check.
35+
36+
For more information, see the
37+
:ref:`security section in the bundle doc <bundle_create_introduction_access_control>`.
2738

2839
.. configuration-block::
2940

3041
.. code-block:: yaml
3142
3243
cmf_create:
33-
role: ROLE_ADMIN
44+
security:
45+
role: ROLE_ADMIN
46+
checker_service: ~
3447
3548
.. code-block:: xml
3649
3750
<?xml version="1.0" charset="UTF-8" ?>
3851
<container xmlns="http://symfony.com/schema/dic/services">
39-
<config xmlns="http://cmf.symfony.com/schema/dic/create"
40-
role="ROLE_ADMIN"
41-
/>
52+
<config xmlns="http://cmf.symfony.com/schema/dic/create">
53+
<security role="ROLE_ADMIN" checker-service="null" />
54+
</config>
4255
</container>
4356
4457
.. code-block:: php
4558
4659
$container->loadFromExtension('cmf_create', array(
47-
'role' => 'ROLE_ADMIN',
60+
'security' => array(
61+
'role' => 'ROLE_ADMIN',
62+
'checker_service' => null,
63+
),
4864
));
4965
5066
.. _config-create-persistence:

reference/configuration/menu.rst

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ persistence configuration has the following configuration:
2727
enabled: false
2828
menu_basepath: /cms/menu
2929
content_basepath: ~
30+
prefetch: 10
3031
manager_name: ~
3132
menu_document_class: Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\Menu
3233
node_document_class: Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\MenuNode
@@ -46,6 +47,7 @@ persistence configuration has the following configuration:
4647
enabled="false"
4748
menu-basepath="/cms/menu"
4849
content-basepath="null"
50+
prefetch="10"
4951
manager-name="null"
5052
menu-document-class="null"
5153
node-document-class="null"
@@ -66,6 +68,7 @@ persistence configuration has the following configuration:
6668
'enabled' => false,
6769
'menu_basepath' => '/cms/menu',
6870
'content_basepath' => null,
71+
'prefetch' => 10,
6972
'manager_name' => null,
7073
'menu_document_class' => null,
7174
'node_document_class' => null,
@@ -82,11 +85,6 @@ enabled
8285

8386
.. include:: partials/persistence_phpcr_enabled.rst.inc
8487

85-
manager_name
86-
""""""""""""
87-
88-
.. include:: partials/persistence_phpcr_manager_name.rst.inc
89-
9088
menu_basepath
9189
"""""""""""""
9290

@@ -115,17 +113,40 @@ the content branch of the document hierarchy in forms.
115113
If the :doc:`CoreBundle <../../bundles/core/index>` is registered, this will default to
116114
the value of ``%cmf_core.persistence.phpcr.basepath%/content``
117115

118-
menu_document
119-
"""""""""""""
116+
.. versionadded:: 1.1
117+
118+
The prefetch functionality was added in MenuBundle 1.1.
119+
120+
prefetch
121+
""""""""
122+
123+
**type**: ``integer`` **default**: ``10``
124+
125+
When rendering a menu, the whole menu tree needs to be loaded. To reduce the
126+
number of database requests that PHPCR needs to make, this setting makes the
127+
tree loader prefetch all menu nodes in one call.
128+
129+
``10`` should be enough for most cases, if you have deeper menu structures you
130+
might want to increase this.
131+
132+
To disable menu prefetch completely, set this option to ``0``.
133+
134+
manager_name
135+
""""""""""""
136+
137+
.. include:: partials/persistence_phpcr_manager_name.rst.inc
138+
139+
menu_document_class
140+
"""""""""""""""""""
120141

121142
**type**: ``string`` **default**: ``Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\Menu``
122143

123144
Specifies the document class which should represent an entire menu.
124145

125146
This setting is used by the admin class.
126147

127-
node_document
128-
"""""""""""""
148+
node_document_class
149+
"""""""""""""""""""
129150

130151
**type**: ``string`` **default**: ``Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\MenuNode``
131152

0 commit comments

Comments
 (0)