@@ -14,6 +14,14 @@ In this chapter, you will learn how to work with the Doctrine PHPCR-ODM.
14
14
Read more about choosing the correct storage layer in
15
15
:doc: `../cookbook/database/choosing_storage_layer `
16
16
17
+ .. note ::
18
+
19
+ This chapter assumes you are using a Symfony setup with PHPCR-ODM already
20
+ set up, like the :doc: `CMF Standard Edition <installation >` or the
21
+ :doc: `CMF sandbox <../cookbook/editions/cmf_sandbox >`. See
22
+ :doc: `../bundles/phpcr_odm/introduction ` for how to set up PHPCR-ODM in
23
+ your applications.
24
+
17
25
PHPCR: A Tree Structure
18
26
-----------------------
19
27
@@ -34,10 +42,9 @@ Multilanguage support.
34
42
.. sidebar :: PHPCR Implementations
35
43
36
44
In order to let the Doctrine PHPCR-ODM communicate with the PHPCR, a PHPCR
37
- implementation is needed. `Jackalope `_ is the reference PHPCR implementation,
38
- which can work with `Apache Jackrabbit `_ (with the `jackalope-jackrabbit `_
39
- package) and with Doctrine DBAL (providing support for postgres, sqlite
40
- and mysql) with the `jackalope-doctrine-dbal `_ package.
45
+ implementation is needed. See
46
+ ":doc: `../cookbook/database/choosing_phpcr_implementation `" for an overview
47
+ of the available implementations.
41
48
42
49
A Simple Example: A Task
43
50
------------------------
@@ -94,30 +101,30 @@ class via annotations:
94
101
// src/Acme/TaskBundle/Document/Task.php
95
102
namespace Acme\TaskBundle\Document;
96
103
97
- use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCR ;
104
+ use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM ;
98
105
99
106
/**
100
- * @PHPCR \Document()
107
+ * @PHPCRODM \Document()
101
108
*/
102
109
class Task
103
110
{
104
111
/**
105
- * @PHPCR \Id()
112
+ * @PHPCRODM \Id()
106
113
*/
107
114
protected $id;
108
115
109
116
/**
110
- * @PHPCR \String()
117
+ * @PHPCRODM \String()
111
118
*/
112
119
protected $description;
113
120
114
121
/**
115
- * @PHPCR \Boolean()
122
+ * @PHPCRODM \Boolean()
116
123
*/
117
124
protected $done = false;
118
125
119
126
/**
120
- * @PHPCR \ParentDocument()
127
+ * @PHPCRODM \ParentDocument()
121
128
*/
122
129
protected $parentDocument;
123
130
}
@@ -168,8 +175,8 @@ After this, you have to create getters and setters for the properties.
168
175
``Nodename ``.
169
176
170
177
A Document must have an id property. This represents the full path (parent
171
- + name) of the Document. This will be set by Doctrine by default and it is
172
- not recommend to use the id to determine the location of a Document.
178
+ path + name) of the Document. This will be set by Doctrine by default and
179
+ it is not recommend to use the id to determine the location of a Document.
173
180
174
181
For more information about identifier generation strategies, refer to the
175
182
`doctrine documentation `_
@@ -178,11 +185,11 @@ After this, you have to create getters and setters for the properties.
178
185
179
186
You can also check out Doctrine's `Basic Mapping Documentation `_ for all
180
187
details about mapping information. If you use annotations, you'll need to
181
- prepend all annotations with ``PHPCR \ ``, which is the name of the imported
182
- namespace (e.g. ``PHPCR \Document(..) ``), this is not shown in Doctrine's
183
- documentation. You'll also need to include the use
184
- ``use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCR ; `` statement, which
185
- imports the PHPCR annotations prefix.
188
+ prepend all annotations with ``@PHPCRODM \ ``, which is the name of the imported
189
+ namespace (e.g. ``@PHPCRODM \Document(..) ``), this is not shown in Doctrine's
190
+ documentation. You'll also need to include the
191
+ ``use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM ; `` statement to
192
+ import the PHPCR annotations prefix.
186
193
187
194
Persisting Documents to PHPCR
188
195
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -331,14 +338,14 @@ Doctrine, it's already managed.
331
338
Deleting an Object
332
339
~~~~~~~~~~~~~~~~~~
333
340
334
- Deleting an object is very similar, but requires a call to the ``remove() `` method
335
- of the document manager after you fetched the document from PHPCR::
341
+ Deleting an object is very similar, but requires a call to the ``remove() ``
342
+ method of the document manager after you fetched the document from PHPCR::
336
343
337
344
$documentManager->remove($task);
338
345
$documentManager->flush();
339
346
340
- As you might expect, the ``remove() `` method notifies Doctrine that you'd like to
341
- remove the given document from PHPCR. The actual delete operation
347
+ As you might expect, the ``remove() `` method notifies Doctrine that you'd like
348
+ to remove the given document from PHPCR. The actual delete operation
342
349
however, is not actually executed until the ``flush() `` method is called.
343
350
344
351
Summary
@@ -351,19 +358,16 @@ mapping metadata information to map an object's data to a particular database
351
358
table.
352
359
353
360
And even though Doctrine revolves around a simple concept, it's incredibly
354
- powerful, allowing you to create complex queries and subscribe to events that
355
- allow you to take different actions as objects go through their persistence
356
- lifecycle.
361
+ powerful, allowing you to ` create complex queries `_ and
362
+ :doc: ` subscribe to events < ../bundles/phpcr_odm/events >` that allow you to
363
+ take different actions as objects go through their persistence lifecycle.
357
364
358
365
.. _`Doctrine PHPCR-ODM` : http://docs.doctrine-project.org/projects/doctrine-phpcr-odm/en/latest/index.html
359
366
.. _`PHP Content Repository` : http://phpcr.github.io/
360
367
.. _`JSR-283 specification` : http://jcp.org/en/jsr/detail?id=283
361
368
.. _`Doctrine ORM` : http://symfony.com/doc/current/book/doctrine.html
362
- .. _`Jackalope` : http://jackalope.github.io/
363
- .. _`Apache Jackrabbit` : http://jackrabbit.apache.org/
364
- .. _`jackalope-jackrabbit` : https://github.com/jackalope/jackalope-jackrabbit
365
- .. _`jackalope-doctrine-dbal` : https://github.com/jackalope/jackalope-doctrine-dbal
366
369
.. _`doctrine documentation` : http://docs.doctrine-project.org/projects/doctrine-phpcr-odm/en/latest/reference/basic-mapping.html#basicmapping-identifier-generation-strategies
367
370
.. _`Basic Mapping Documentation` : http://docs.doctrine-project.org/projects/doctrine-phpcr-odm/en/latest/reference/annotations-reference.html
368
371
.. _`the QueryBuilder documentation` : http://docs.doctrine-project.org/projects/doctrine-phpcr-odm/en/latest/reference/query-builder.html
372
+ .. _`create complex queries` : http://docs.doctrine-project.org/projects/doctrine-phpcr-odm/en/latest/reference/query-builder.html
369
373
.. _`Custom Repository Classes` : http://symfony.com/doc/current/book/doctrine.html#custom-repository-classes
0 commit comments