Skip to content
This repository
Newer
Older
100644 960 lines (745 sloc) 33.129 kb
9cada556 »
2010-12-06 Initial import of the code
1 PHPCR ODM for Doctrine2
2 =======================
3
84f2472a »
2011-11-23 cleaning up setup and bootstrap documentation in README
4 # Current Status
9cada556 »
2010-12-06 Initial import of the code
5
3f68baab »
2011-09-27 updated status and removed bogus support for ArrayField (this is mult…
6 * most key features implemented
619da452 »
2011-06-24 removed alias from examples, its now the class that is stored in phpcr
7 * alpha stage
f5e86f77 »
2011-11-17 adding link to issue tracker to readme
8 * [Issue Tracker](http://www.doctrine-project.org/jira/browse/PHPCR)
2aa90173 »
2011-11-15 added status icon
9 * [![Build Status](https://secure.travis-ci.org/doctrine/phpcr-odm.png)](http://travis-ci.org/doctrine/phpcr-odm)
9cada556 »
2010-12-06 Initial import of the code
10
84f2472a »
2011-11-23 cleaning up setup and bootstrap documentation in README
11
12 # TODO
9cada556 »
2010-12-06 Initial import of the code
13
6284c15f »
2011-08-08 adjusting readme for the bootstrap with repository factory
14 * have the register-system-node-types command provide api conform node type definition as well to support other implementations
766428a2 »
2011-05-27 some updates to the readme
15 * write documentation
16 * expand test suite
31b8fafb »
2011-12-13 doc cleanups
17 * translations
18 * make it work without the @Locale field too (store locale in meta instead on document instance)
19 * provide a method to get a detached translated document so the relations can be translated automatically
a9c8cf70 »
2010-12-09 Added basic usage instructions
20
84f2472a »
2011-11-23 cleaning up setup and bootstrap documentation in README
21 # Preconditions
22
23 * php >= 5.3
24 * libxml version >= 2.7.0 (due to a bug in libxml [http://bugs.php.net/bug.php?id=36501](http://bugs.php.net/bug.php?id=36501))
27b31d05 »
2012-02-21 updated documentation
25 * phpunit >= 3.6 and wget (if you want to run the tests)
84f2472a »
2011-11-23 cleaning up setup and bootstrap documentation in README
26
27 # Installation
28
29 If you use the PHPCR ODM **Symfony Bundle**, please look into the README of the bundle.
30 This documentation explains how to use PHPCR ODM outside of symfony, which requires some
31 manual initialization.
32
33
34 ## Clone the repository and initialize all dependencies (submodules)
35
36 git clone git://github.com/doctrine/phpcr-odm.git
37 cd phpcr-odm
38 git submodule update --init --recursive
39
c9a04d1c »
2011-12-18 Document the Midgard2 option for ODM
40 ## Install a PHPCR provider
84f2472a »
2011-11-23 cleaning up setup and bootstrap documentation in README
41
c9a04d1c »
2011-12-18 Document the Midgard2 option for ODM
42 PHPCR ODM uses the [PHP Content Repository API](http://phpcr.github.com/) for storage. You need to install one of the available providers:
84f2472a »
2011-11-23 cleaning up setup and bootstrap documentation in README
43
c9a04d1c »
2011-12-18 Document the Midgard2 option for ODM
44 ### Install Jackrabbit
45
46 Jackalope with the Jackrabbit backend is the only PHPCR implementation that is enough feature complete for the PHPCR ODM.
84f2472a »
2011-11-23 cleaning up setup and bootstrap documentation in README
47
48 Follow [Running Jackrabbit Server](https://github.com/jackalope/jackalope/wiki/Running-a-jackrabbit-server) from the Jackalope wiki.
49
c9a04d1c »
2011-12-18 Document the Midgard2 option for ODM
50 ### Install Midgard2 PHPCR
51
57586a53 »
2012-01-16 add more doc about the id generators, reformat long lines
52 [Midgard2](https://github.com/midgardproject/phpcr-midgard2) is a PHPCR
53 provider that provides most of the functionality needed for PHPCR ODM, and can
54 persist your content in typical relational databases like SQLite and MySQL.
55 Midgard2 only needs [a PHP extension](https://github.com/midgardproject/midgard-php5)
56 to run. On typical Linux setups getting the extension is as easy as:
c9a04d1c »
2011-12-18 Document the Midgard2 option for ODM
57
58 $ sudo apt-get install php5-midgard2
59
84f2472a »
2011-11-23 cleaning up setup and bootstrap documentation in README
60 ## Enable the console
61
62 The console provides a bunch of useful commands:
63
64 # in the phpcr-odm root directoy
65 cp cli-config.php.dist cli-config.php
66 # edit the file and adjust if needed - the defaults expect all submodules in place
a9c8cf70 »
2010-12-09 Added basic usage instructions
67
84f2472a »
2011-11-23 cleaning up setup and bootstrap documentation in README
68 Now running ``php bin/phpcr`` will show you a list of the available commands.
69 ``php bin/phpcr help <cmd>`` displays additional information for that command.
09c55913 »
2011-03-19 Added Child annotation and File document
70
84f2472a »
2011-11-23 cleaning up setup and bootstrap documentation in README
71
72 ## Register the phpcr:managed node type
73
74 PHPCR ODM uses a [custom node type](https://github.com/doctrine/phpcr-odm/wiki/Custom-node-type-phpcr%3Amanaged)
75 to track meta information without interfering with your content.
76 We provide a command that makes it trivial to register this type and the phpcr namespace.
77
78 php bin/phpcr doctrine:phpcr:register-system-node-types
79
27b31d05 »
2012-02-21 updated documentation
80 ## Running the tests
81 This examples shows how to run the tests for jackrabbit. You can run the tests for the other backends (doctrine_dbal, midgard_mysql, midgard_sqlite) by replacing jackrabbit with the same commands. Just replace jackrabbit with the name of the backend you want to run.
82
83 1. Make sure you have installed the submodules
84 2. Run this command to download jackrabbit and launch it (requires wget)
85
86 ./tests/travis_jackrabbit.sh
87
88 3. Run the tests:
89
90 phpunit -c tests/phpunit_jackrabbit.xml.dist
84f2472a »
2011-11-23 cleaning up setup and bootstrap documentation in README
91
92 # Bootstrapping
93
94 ## Set up autoloading
95
96 For an inspiration for the autoloading, have a look at ``cli-config.php.dist``.
97 You need to make sure that the following paths are autoloaded (all paths relative to the phpcr-odm root directory):
98
e797e2a1 »
2011-11-23 fix markup to look nice on github
99 ```php
100 'Doctrine\ODM' => 'lib',
101 'Doctrine\Common' => 'lib/vendor/doctrine-common/lib',
102 'Symfony\Component\Console' => 'lib/vendor/jackalope/lib/phpcr-utils/lib/vendor',
103 'Symfony' => 'lib/vendor,
104 'PHPCR\Util' => 'lib/vendor/jackalope/lib/phpcr-utils/src',
105 'PHPCR' => 'lib/vendor/jackalope/lib/phpcr/src',
106 'Jackalope' => 'lib/vendor/jackalope/src',
c9a04d1c »
2011-12-18 Document the Midgard2 option for ODM
107 'Midgard\PHPCR' => 'lib/vendor/Midgard/PHPCR/src',
e797e2a1 »
2011-11-23 fix markup to look nice on github
108 'Doctrine\DBAL' => 'lib/vendor/jackalope/lib/vendor/doctrine-dbal',
109 ```
84f2472a »
2011-11-23 cleaning up setup and bootstrap documentation in README
110
111
112 ## Define a mapping driver
113
114 You can choose between the drivers for annotations, xml and yml configuration files:
a9c8cf70 »
2010-12-09 Added basic usage instructions
115
e797e2a1 »
2011-11-23 fix markup to look nice on github
116 ```php
117 <?php
118 // Annotation driver
119 $reader = new \Doctrine\Common\Annotations\AnnotationReader();
120 $driver = new \Doctrine\ODM\PHPCR\Mapping\Driver\AnnotationDriver($reader, array('/path/to/your/document/classes'));
a9c8cf70 »
2010-12-09 Added basic usage instructions
121
e797e2a1 »
2011-11-23 fix markup to look nice on github
122 // Xml driver
123 $driver = new \Doctrine\ODM\PHPCR\Mapping\Driver\XmlDriver(array('/path/to/your/mapping/files'));
a9c8cf70 »
2010-12-09 Added basic usage instructions
124
e797e2a1 »
2011-11-23 fix markup to look nice on github
125 // Yaml driver
126 $driver = new \Doctrine\ODM\PHPCR\Mapping\Driver\YamlDriver(array('/path/to/your/mapping/files'));
127 ```
a9c8cf70 »
2010-12-09 Added basic usage instructions
128
84f2472a »
2011-11-23 cleaning up setup and bootstrap documentation in README
129
130 ## Bootstrap the PHPCR session
131
c9a04d1c »
2011-12-18 Document the Midgard2 option for ODM
132 With the Jackrabbit provider, the PHPCR ODM connection can be configured with:
a9c8cf70 »
2010-12-09 Added basic usage instructions
133
e797e2a1 »
2011-11-23 fix markup to look nice on github
134 ```php
135 <?php
136 $repository = \Jackalope\RepositoryFactoryJackrabbit::getRepository(
137 array('jackalope.jackrabbit_uri' => 'http://localhost:8080/server'));
138 $credentials = new \PHPCR\SimpleCredentials('user', 'pass');
139 $session = $repository->login($credentials, 'your_workspace');
140 ```
a9c8cf70 »
2010-12-09 Added basic usage instructions
141
c9a04d1c »
2011-12-18 Document the Midgard2 option for ODM
142 With Midgard2, the connection configuration (using MySQL as an example) would be something like:
143
144 ```php
145 <?php
146 $repository = \Midgard\PHPCR\RepositoryFactory::getRepository(
147 array(
148 'midgard2.configuration.db.type' => 'MySQL',
149 'midgard2.configuration.db.name' => 'phpcr',
150 'midgard2.configuration.db.host' => 'localhost',
151 'midgard2.configuration.db.username' => 'midgard',
152 'midgard2.configuration.db.password' => 'midgard',
153 'midgard2.configuration.blobdir' => '/some/path/for/blobs',
154 'midgard2.configuration.db.init' => true
155 )
156 );
157 $credentials = new \PHPCR\SimpleCredentials('admin', 'password');
158 $session = $repository->login($credentials, 'your_workspace');
159 ```
160
57586a53 »
2012-01-16 add more doc about the id generators, reformat long lines
161 Note that the `midgard2.configuration.db.init` setting should only be used the
162 first time you connect to the Midgard2 repository. After that the database is
163 ready and this setting should be removed for better performance.
84f2472a »
2011-11-23 cleaning up setup and bootstrap documentation in README
164
165 ## Initialize the DocumentManager
a9c8cf70 »
2010-12-09 Added basic usage instructions
166
e797e2a1 »
2011-11-23 fix markup to look nice on github
167 ```php
168 <?php
169 $config = new \Doctrine\ODM\PHPCR\Configuration();
170 $config->setMetadataDriverImpl($driver);
171
172 $dm = new \Doctrine\ODM\PHPCR\DocumentManager($session, $config);
173 ```
a9c8cf70 »
2010-12-09 Added basic usage instructions
174
84f2472a »
2011-11-23 cleaning up setup and bootstrap documentation in README
175 Now you are ready to use the PHPCR ODM
176
a9c8cf70 »
2010-12-09 Added basic usage instructions
177
84f2472a »
2011-11-23 cleaning up setup and bootstrap documentation in README
178 # Example usage
a9c8cf70 »
2010-12-09 Added basic usage instructions
179
e797e2a1 »
2011-11-23 fix markup to look nice on github
180 ```php
181 <?php
57586a53 »
2012-01-16 add more doc about the id generators, reformat long lines
182 // fetching a document by PHPCR path (id in PHPCR ODM lingo)
e797e2a1 »
2011-11-23 fix markup to look nice on github
183 $user = $dm->getRepository('Namespace\For\Document\User')->find('/bob');
184 //or let the odm find the document class for you
185 $user = $dm->find('/bob');
186
187 // create a new document
188 $newUser = new \Namespace\For\Document\User();
189 $newUser->username = 'Timmy';
190 $newUser->email = 'foo@example.com';
191 $newUser->path = '/timmy';
192 // make the document manager know this document
193 // this will create the node in phpcr but not read the fields or commit
194 // the changes yet.
195 $dm->persist($newUser);
196
197 // store all changes, insertions, etc. with the storage backend
198 $dm->flush();
199
9556fc7f »
2012-02-13 adding some doc for move operation #103
200 // move/rename a document in the tree
201 $dm->move($newUser, '/tommy');
202 $dm->flush();
203
204 // make sure there is no documents left thinking $newUser at the old path
205 $dm->clear();
206
e797e2a1 »
2011-11-23 fix markup to look nice on github
207 // run a query
7a27badb »
2012-01-16 adding querybuilder to DocumentManager
208 $qb = $dm->createQueryBuilder();
209
210 // SELECT * FROM nt:unstructured WHERE name NOT IS NULL
10d85453 »
2012-01-16 fixing code error in QueryBuilder example
211 $factory = $qb->getQOMFactory();
7a27badb »
2012-01-16 adding querybuilder to DocumentManager
212 $qb->select($factory->selector('nt:unstructured'))
213 ->where($factory->propertyExistance('name'))
214 ->setFirstResult(10)
215 ->setMaxResults(10)
216 ->execute();
217 $result = $dm->getDocumentsByQuery($qb->getQuery());
e797e2a1 »
2011-11-23 fix markup to look nice on github
218 foreach ($result as $document) {
219 echo $document->getId();
220 }
7a27badb »
2012-01-16 adding querybuilder to DocumentManager
221
5f14e0ac »
2011-12-13 document that remove removes everything under the path
222 // remove a document - and all documents in paths under that one!
223 $dm->remove($newUser);
224 $dm->flush();
e797e2a1 »
2011-11-23 fix markup to look nice on github
225 ```
7e2306dc »
2011-03-21 adding documentation on available annotations in the readme
226
84f2472a »
2011-11-23 cleaning up setup and bootstrap documentation in README
227 # Document Classes
7e2306dc »
2011-03-21 adding documentation on available annotations in the readme
228
57586a53 »
2012-01-16 add more doc about the id generators, reformat long lines
229 You write your own document classes that will be mapped to and from the phpcr
230 database by doctrine. The documents are usually simple
7e2306dc »
2011-03-21 adding documentation on available annotations in the readme
231
b7a758e5 »
2011-11-07 Adding GitHub flavored markdown for PHP snippets
232 ```php
233 <?php
234 namespace Acme\SampleBundle\Document;
ae82c9b3 »
2011-06-07 updated README
235
b7a758e5 »
2011-11-07 Adding GitHub flavored markdown for PHP snippets
236 use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM;
ae82c9b3 »
2011-06-07 updated README
237
b7a758e5 »
2011-11-07 Adding GitHub flavored markdown for PHP snippets
238 /**
239 * @PHPCRODM\Document
240 */
241 class MyDocument
242 {
7e2306dc »
2011-03-21 adding documentation on available annotations in the readme
243 /**
b7a758e5 »
2011-11-07 Adding GitHub flavored markdown for PHP snippets
244 * @PHPCRODM\Id()
7e2306dc »
2011-03-21 adding documentation on available annotations in the readme
245 */
b7a758e5 »
2011-11-07 Adding GitHub flavored markdown for PHP snippets
246 public $path;
247 /**
248 * @PHPCRODM\String()
249 */
250 public $title;
251
252 /**
253 * @PHPCRODM\String()
254 */
255 public $content;
256 }
257 ```
7e2306dc »
2011-03-21 adding documentation on available annotations in the readme
258
57586a53 »
2012-01-16 add more doc about the id generators, reformat long lines
259 Note that there are basic Document classes for the standard PHPCR node types
260 ``nt:file``, ``nt:folder`` and ``nt:resource``. See lib/Doctrine/ODM/PHPCR/Document/
261
d446b2ff »
2011-05-12 updated readme with information about the Child annotation and the de…
262
84f2472a »
2011-11-23 cleaning up setup and bootstrap documentation in README
263 ## Storing documents in the repository: Id Generator Strategy
d85dcab1 »
2011-04-12 tweaked the readme in several places, added documentation on id gener…
264
57586a53 »
2012-01-16 add more doc about the id generators, reformat long lines
265 Every document needs an ``id``. This is used to later retrieve the document
266 from storage again. The id is the path in the content repository to the node
267 storing the document.
268
269 It is possible to choose the generator strategy.
270 Currently, there are 3 strategies available:
271
272 * With the default "assigned id" you need to assign a path to your id field and
273 have to make sure yourself that the parent exists.
274 * The "parent and name" strategy determines the path from the @ParentDocument
275 and the @Nodename fields. This is the most failsave strategy.
276 * The repository strategy lets your custom repository determine an id so you
277 can implement any logic you might need.
278
279
280 ### Assigned Id
281
282 This is the default but very unsafe strategy. You need to manually assign the
283 path to the id field.
284 A document is not allowed to have no parent, so you need to make sure that the
285 parent of that path already exists. (It can be a plain PHPCR node not
286 representing any PHPCR-ODM document, though.)
287
288 ```php
289 <?php
290 use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM;
291
292 /**
293 * @PHPCRODM\Document
294 */
295 class Document
296 {
297 /** @PHPCRODM\Id */
298 public $id;
299 }
eb5f0190 »
2011-04-12 some more doc tweaking
300
57586a53 »
2012-01-16 add more doc about the id generators, reformat long lines
301 $doc = new Document();
302 $doc->id = '/test';
303 ```
304
305 ### Parent and name strategy (recommended)
306
307 This strategy uses the @Nodename (desired name of this node) and
308 @ParentDocument (PHPCR-ODM document that is the parent). The id is generated
309 as the id of the parent concatenated with '/' and the Nodename.
310
311 If you supply a ParentDocument annotation, the strategy is automatically set to
312 parent. This strategy will check the parent and the name and will fall back to
313 the assigned id if either is missing.
314
315
316 ```php
317 <?php
318 use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM;
319
320 /**
321 * @PHPCRODM\Document
322 */
323 class Document
324 {
325 /** @PHPCRODM\ParentDocument */
326 public $parent;
327 /** @PHPCRODM\Nodename */
328 public $nodename;
329 }
eb5f0190 »
2011-04-12 some more doc tweaking
330
57586a53 »
2012-01-16 add more doc about the id generators, reformat long lines
331 $doc = new Document();
332 $doc->parent = $dm->find('/test');
333 $doc->nodename = 'mynode';
334 // => /test/mynode
335 ```
c0add99b »
2011-10-22 added simple functionality to create documents with parent and name
336
57586a53 »
2012-01-16 add more doc about the id generators, reformat long lines
337 ### Repository strategy
09fad597 »
2011-10-11 xadding parent annotation, first partial commit. exceptions on changi…
338
57586a53 »
2012-01-16 add more doc about the id generators, reformat long lines
339 If you need custom logic to determine the id, you can explicitly set the
340 strategy to "repository". You need to define the repositoryClass which will
341 handle the task of generating the id from the information in the document.
342 This gives you full control how you want to build the path.
d85dcab1 »
2011-04-12 tweaked the readme in several places, added documentation on id gener…
343
b7a758e5 »
2011-11-07 Adding GitHub flavored markdown for PHP snippets
344 ```php
345 <?php
346 namespace Acme\SampleBundle\Document;
347
348 use Doctrine\ODM\PHPCR\Id\RepositoryIdInterface;
349 use Doctrine\ODM\PHPCR\DocumentRepository as BaseDocumentRepository;
350 use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM;
351
352 /**
353 * @PHPCRODM\Document(repositoryClass="Acme\SampleBundle\DocumentRepository")
354 */
355 class Document
356 {
357 /** @PHPCRODM\Id(strategy="repository") */
358 public $id;
359 /** @PHPCRODM\String(name="title") */
360 public $title;
361 }
362
363 class DocumentRepository extends BaseDocumentRepository implements RepositoryIdInterface
364 {
d85dcab1 »
2011-04-12 tweaked the readme in several places, added documentation on id gener…
365 /**
b7a758e5 »
2011-11-07 Adding GitHub flavored markdown for PHP snippets
366 * Generate a document id
367 *
368 * @param object $document
369 * @return string
d85dcab1 »
2011-04-12 tweaked the readme in several places, added documentation on id gener…
370 */
b7a758e5 »
2011-11-07 Adding GitHub flavored markdown for PHP snippets
371 public function generateId($document)
d85dcab1 »
2011-04-12 tweaked the readme in several places, added documentation on id gener…
372 {
57586a53 »
2012-01-16 add more doc about the id generators, reformat long lines
373 return '/functional/'.$document->title;
d85dcab1 »
2011-04-12 tweaked the readme in several places, added documentation on id gener…
374 }
b7a758e5 »
2011-11-07 Adding GitHub flavored markdown for PHP snippets
375 }
376 ```
d85dcab1 »
2011-04-12 tweaked the readme in several places, added documentation on id gener…
377
57586a53 »
2012-01-16 add more doc about the id generators, reformat long lines
378 ## Available field annotations
d85dcab1 »
2011-04-12 tweaked the readme in several places, added documentation on id gener…
379
7e2306dc »
2011-03-21 adding documentation on available annotations in the readme
380 <table>
57586a53 »
2012-01-16 add more doc about the id generators, reformat long lines
381 <tr>
8f150f98 »
2012-02-02 Merge remote branch 'upstream/master' into versioning, remove alias f…
382 <td>Id:</td>
383 <td>Read only except on new documents with the assigned id strategy. The
384 PHPCR path to this node. (see above). For new nodes not using the
57586a53 »
2012-01-16 add more doc about the id generators, reformat long lines
385 default strategy, it is populated during the persist() operation.
386 </td>
387 </tr>
388 <tr>
8f150f98 »
2012-02-02 Merge remote branch 'upstream/master' into versioning, remove alias f…
389 <td>Uuid:</td>
390 <td>Read only (generated on flush). The unique id of this node. (only allowed if node is referenceable).</td>
57586a53 »
2012-01-16 add more doc about the id generators, reformat long lines
391 </tr>
392 <tr>
393 <td> Node: </td>
8f150f98 »
2012-02-02 Merge remote branch 'upstream/master' into versioning, remove alias f…
394 <td>The PHPCR\NodeInterface instance for direct access. This is populated
57586a53 »
2012-01-16 add more doc about the id generators, reformat long lines
395 as soon as you register the document with the manager using persist().
396 </td>
397 </tr>
398 <tr>
8f150f98 »
2012-02-02 Merge remote branch 'upstream/master' into versioning, remove alias f…
399 <td>Nodename:</td>
400 <td>Read only except for new documents with the parent and name strategy.
401 For new nodes with other id strategies, it is populated during the
57586a53 »
2012-01-16 add more doc about the id generators, reformat long lines
402 persist() operation.
8f150f98 »
2012-02-02 Merge remote branch 'upstream/master' into versioning, remove alias f…
403 The name of the PHPCR node (this is the part of the path after the last
404 '/' in the id).
57586a53 »
2012-01-16 add more doc about the id generators, reformat long lines
405 </td>
406 </tr>
407 <tr>
8f150f98 »
2012-02-02 Merge remote branch 'upstream/master' into versioning, remove alias f…
408 <td>ParentDocument:</td>
409 <td>Read only except for new documents with the parent and name strategy.
410 The parent document of this document. If the repository knows the
411 document class, the document will be of that type, otherwise
412 Doctrine\ODM\PHPCR\Document\Generic is used.
57586a53 »
2012-01-16 add more doc about the id generators, reformat long lines
413 </td>
414 </tr>
415 <tr>
8f150f98 »
2012-02-02 Merge remote branch 'upstream/master' into versioning, remove alias f…
416 <td>Child(name=x):</td>
9ebc7a2f »
2012-01-16 precise doc about @Child annotation
417 <td>Map the child with name x to this field. If name is not specified, the
418 name of the annotated varialbe is used.
419 </td>
57586a53 »
2012-01-16 add more doc about the id generators, reformat long lines
420 </tr>
421 <tr>
8f150f98 »
2012-02-02 Merge remote branch 'upstream/master' into versioning, remove alias f…
422 <td>Children(filter=x): </td>
9ebc7a2f »
2012-01-16 precise doc about @Child annotation
423 <td>Map the collection of children to this field. Filter is optional and
424 works like the parameter in <a href="http://phpcr.github.com/doc/html/phpcr/nodeinterface.html#getNodes()">PHPCR Node::getNodes()</a>
57586a53 »
2012-01-16 add more doc about the id generators, reformat long lines
425 </td>
426 </tr>
427 <tr>
8f150f98 »
2012-02-02 Merge remote branch 'upstream/master' into versioning, remove alias f…
428 <td>ReferenceOne(targetDocument="myDocument", weak=false): (*)</td>
57586a53 »
2012-01-16 add more doc about the id generators, reformat long lines
429 <td>Refers a document of the type myDocument. The default is a weak
430 reference. By optionaly specifying weak=false you get a hard reference.
431 It is optional to specify the targetDocument, you can reference any
432 document type.
433 </td>
434 </tr>
435 <tr>
436 <td> ReferenceMany(targetDocument="myDocument", weak=false): (*)</td>
437 <td>Same as ReferenceOne except that you can refer many documents with the
438 same document and reference type. If you dont't specify targetDocument
439 you can reference documents of mixed types in the same property.
440 </td>
441 </tr>
442 <tr>
8f150f98 »
2012-02-02 Merge remote branch 'upstream/master' into versioning, remove alias f…
443 <td>Referrers(filter="x", referenceType=null): </td>
444 <td>Read only, the inverse of the Reference field. This field is a
445 collection of all documents that refer this document. The ``filter``
446 is optional. If set, it is used as parameter ``name`` for <a href="http://phpcr.github.com/doc/html/phpcr/nodeinterface.html#getWeakReferences%28%29">Node::getReferences()<a/>
57586a53 »
2012-01-16 add more doc about the id generators, reformat long lines
447 or <a href="http://phpcr.github.com/doc/html/phpcr/nodeinterface.html#getWeakReferences%28%29">Node::getWeakReferences()</a>.
448 You can also specify an optional referenceType, weak or hard, to only
449 get documents that have either a weak or a hard reference to this
450 document. If you specify null then all documents with weak or hard
451 references are fetched, which is also the default behavior.
452 </td>
453 </tr>
454 <tr>
455 <td>Locale:</td>
456 <td>Indentifies the field that will be used to store the current locale of
457 the document. This annotation is required for translatable documents.
458 </td>
459 </tr>
460 <tr>
2777191b »
2012-02-02 remove unnecessary check. class meta data ensures valid data
461 <td> VersionName:</td>
8f150f98 »
2012-02-02 Merge remote branch 'upstream/master' into versioning, remove alias f…
462 <td>Read only, only populated for detached documents returned by
463 findVersionByName. Stores the version name this document represents.
464 Otherwise its ignored.
465 </td>
466 </tr>
467 <tr>
468 <td>VersionCreated:</td>
469 <td>Read only, only populated for detached documents returned by
470 findVersionByName. Stores the DateTime object when this version was
471 created with the checkin() operation. Otherwise its ignored.
472 </td>
473 </tr>
474 <tr>
57586a53 »
2012-01-16 add more doc about the id generators, reformat long lines
475 <td>
476 String, <br />
477 Binary, <br />
478 Long (alias Int), <br />
479 Decimal, <br />
480 Double (alias Float), <br />
481 Date, <br />
482 Boolean, <br />
483 Name, <br />
484 Path, <br />
485 Uri
486 </td>
487 <td>Map node properties to the document. See
488 <a href="http://phpcr.github.com/doc/html/phpcr/propertytype.html">PHPCR\PropertyType</a>
489 for details about the types.
490 </td>
491 </tr>
7e2306dc »
2011-03-21 adding documentation on available annotations in the readme
492 </table>
493
57586a53 »
2012-01-16 add more doc about the id generators, reformat long lines
494 (*) Note that creating new references with the help of the ReferenceOne/ReferenceMany
495 annotations is only possible if your PHPCR implementation supports programmatically
496 setting the uuid property at node creation.
31b8fafb »
2011-12-13 doc cleanups
497
498 ### Parameters for the property types
499
500 In the parenthesis after the type, you can specify some additional information
501 like the name of the PHPCR property to store the value in.
502
503 <table>
57586a53 »
2012-01-16 add more doc about the id generators, reformat long lines
504 <tr>
505 <td>name</td>
506 <td>The property name to use for storing this field. If not specified,
507 defaults to the php variable name.
508 </td>
509 </tr>
510 <tr>
511 <td>multivalue</td>
512 <td>Set multivalue=true to mark this property as multivalue. It then
513 contains a numerically indexed array of values instead of just one
514 value. For more complex data structures, use child nodes.
515 </td>
516 </tr>
517 <tr>
518 <td>translated</td>
519 <td>Set translated=true to mark this property as being translated. See below.</td>
520 </tr>
31b8fafb »
2011-12-13 doc cleanups
521 </table>
7dc26f31 »
2011-10-08 set uuid for any type that is referenceable and explain what we do. d…
522
b7a758e5 »
2011-11-07 Adding GitHub flavored markdown for PHP snippets
523 ```php
524 <?php
525
526 /**
527 * @PHPCRODM\String(name="categories", multivalue=true)
528 */
529 private $cat;
530 ```
7dc26f31 »
2011-10-08 set uuid for any type that is referenceable and explain what we do. d…
531
7998ed3a »
2011-12-09 Started writing the translations stuff doc
532 # Multilingual documents
533
57586a53 »
2012-01-16 add more doc about the id generators, reformat long lines
534 PHPCR-ODM supports multilingual documents so that you can mark properties as
535 translatable and then make the document manager automatically store the
536 translations.
7998ed3a »
2011-12-09 Started writing the translations stuff doc
537
57586a53 »
2012-01-16 add more doc about the id generators, reformat long lines
538 To use translatable documents you need to use several annotations and some
8f150f98 »
2012-02-02 Merge remote branch 'upstream/master' into versioning, remove alias f…
539 bootstrapping code. Your document annotation must specify a translator type.
7998ed3a »
2011-12-09 Started writing the translations stuff doc
540
541 ```php
542 <?php
543 use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM;
544
545 /**
eb5cbbc9 »
2012-02-01 and we do have doc for versioning too
546 * @PHPCRODM\Document(translator="attribute")
7998ed3a »
2011-12-09 Started writing the translations stuff doc
547 */
548 class Article
549 {
550 /** @PHPCRODM\Id */
551 public $id;
552
553 /**
31b8fafb »
2011-12-13 doc cleanups
554 * The language this document currently is in
7998ed3a »
2011-12-09 Started writing the translations stuff doc
555 * @PHPCRODM\Locale
556 */
57586a53 »
2012-01-16 add more doc about the id generators, reformat long lines
557 public $locale;
7998ed3a »
2011-12-09 Started writing the translations stuff doc
558
31b8fafb »
2011-12-13 doc cleanups
559 /**
560 * Untranslated property
561 * @PHPCRODM\Date
562 */
7998ed3a »
2011-12-09 Started writing the translations stuff doc
563 public $publishDate;
564
31b8fafb »
2011-12-13 doc cleanups
565 /**
566 * Translated property
567 * @PHPCRODM\String(translated=true)
568 */
7998ed3a »
2011-12-09 Started writing the translations stuff doc
569 public $topic;
570
31b8fafb »
2011-12-13 doc cleanups
571 /**
572 * Language specific image
573 * @PHPCRODM\Binary(translated=true)
574 */
575 public $image;
7998ed3a »
2011-12-09 Started writing the translations stuff doc
576 }
577 ```
578
31b8fafb »
2011-12-13 doc cleanups
579 Note that translation always happens on a document level, not on individual fields.
580 With the above document, there is no way to store a new translation for the topic without
581 generating a copy of the image (unless you remove the translated=true from image, but then
582 the image is no longer translated for any language).
583
7998ed3a »
2011-12-09 Started writing the translations stuff doc
584 ## Select the translation strategy
585
586 A translation strategy needs to be selected by adding the `translator` parameter to the @Document annotation.
587 The translation strategy is responsible to actually persist the translated properties.
588
31b8fafb »
2011-12-13 doc cleanups
589 There are two default translation strategies implemented:
7998ed3a »
2011-12-09 Started writing the translations stuff doc
590
591 * **attribute** - will store the translations in attributes of the node containing the translatable properties
592 * **child** - will store the translations in a child node of the node containing the translatable properties
593
594 It is possible to implement other strategies to persist the translations, see below.
595
596 ### Implementing your own translation strategy
597
57586a53 »
2012-01-16 add more doc about the id generators, reformat long lines
598 You may want to implement your own translation strategy to persist the translatable properties of a node.
599 For example if you want all the translations to be stored in a separate branch of you content repository.
7998ed3a »
2011-12-09 Started writing the translations stuff doc
600
601 To do so you need to implement the `Doctrine\ODM\PHPCR\Translation\TranslationStrategy\TranslationStrategyInterface`.
602
603 Then you have to register your translation strategy with the document manager during the bootstrap.
604
605 ```php
606 <?php
607 class MyTranslationStrategy implements Doctrine\ODM\PHPCR\Translation\TranslationStrategy\TranslationStrategyInterface
608 {
609 // ...
610 }
611
612 $dm = new \Doctrine\ODM\PHPCR\DocumentManager($session, $config);
613 $dm->setTranslationStrategy('my_strategy_name', new MyTranslationStrategy());
614 ```
615
616 After registering your new translation strategy you can use it in the @Document annotation:
617
618 ```php
619 <?php
620 /**
00bbd91e »
2012-01-15 removed Document(alias=[..]) support
621 * @PHPCRODM\Document(translator="my_strategy_name")
7998ed3a »
2011-12-09 Started writing the translations stuff doc
622 */
623 class Article
624 {
625 // ...
626 }
627 ```
628
629 ## Select the language chooser strategy
630
31b8fafb »
2011-12-13 doc cleanups
631 The language chooser strategy provides the default language and a list of languages
632 to be used as language fallback order to find the best available translation.
633
634 On reading, PHPCR-ODM tries to find a translation with each of the languages in that
635 list and throws a not found exception if none of the languages exists.
7998ed3a »
2011-12-09 Started writing the translations stuff doc
636
31b8fafb »
2011-12-13 doc cleanups
637 The default language chooser strategy (`Doctrine\ODM\PHPCR\Translation\LocaleChooser\LocaleChooser`) returns
638 a configurable list of languages based on the requested language. On instantiation, you specify
6f977b9f »
2012-01-23 distinguish between default locale and current locale
639 the default locale. This should be your application default locale. It is used to get the default locale order
640 which usually should not vary based on the current locale.
641 Based on the request or whatever criteria you have, you can use setLocale to have the document manager load
642 your document in the right language.
7998ed3a »
2011-12-09 Started writing the translations stuff doc
643
31b8fafb »
2011-12-13 doc cleanups
644 When you bootstrap the document manager, you need to set the language chooser strategy if you have
645 any translatable documents:
7998ed3a »
2011-12-09 Started writing the translations stuff doc
646
647 ```php
648 <?php
649 $localePrefs = array(
650 'en' => array('en', 'de', 'fr'), // When EN is requested try to get a translation first in EN, then DE and finally FR
651 'fr' => array('fr', 'de', 'en'), // When FR is requested try to get a translation first in FR, then DE and finally EN
652 'it' => array('fr', 'de', 'en'), // When IT is requested try to get a translation first in FR, then DE and finally EN
653 );
654
655 $dm = new \Doctrine\ODM\PHPCR\DocumentManager($session, $config);
656 $dm->setLocaleChooserStrategy(new LocaleChooser($localePrefs, 'en'));
657 ```
658
31b8fafb »
2011-12-13 doc cleanups
659 You can write your own strategy by implementing `Doctrine\ODM\PHPCR\Translation\LocaleChooser\LocaleChooserInterface`.
660 This is useful to determine the default language based on some logic, or provide fallback orders based on user preferences.
661
7998ed3a »
2011-12-09 Started writing the translations stuff doc
662
663 ## Mark a field as @Locale
664
db1d491b »
2012-02-03 adjust doc about @Locale annotation (its not mandatory anymore)
665 If you annotate a field with this annotation, the current locale of the
666 document is tracked there. It is populated when finding the document,
667 updated when you call bindTranslation and also taken into account when
668 you flush the document.
7998ed3a »
2011-12-09 Started writing the translations stuff doc
669
670 ```php
671 <?php
672 /**
673 * @PHPCRODM\Locale
674 */
57586a53 »
2012-01-16 add more doc about the id generators, reformat long lines
675 public $locale;
7998ed3a »
2011-12-09 Started writing the translations stuff doc
676 ```
677
db1d491b »
2012-02-03 adjust doc about @Locale annotation (its not mandatory anymore)
678 ## Defining properties as translatable
7998ed3a »
2011-12-09 Started writing the translations stuff doc
679
680 A property is set as translatable adding the `translatable` parameter to the field definition annontation.
681
682 ```php
683 <?php
684 /** @PHPCRODM\String(translated=true) */
685 public $topic;
686 ```
687
688 You can set any type of property as translatable.
689
31b8fafb »
2011-12-13 doc cleanups
690 Having at least one property marked as translatable will make the whole document translatable and thus forces you to have a @Locale field (see above).
7998ed3a »
2011-12-09 Started writing the translations stuff doc
691
692 Please note that internally, the translatable properties will be persisted by the translator strategy, not directly by the document manager.
693
31b8fafb »
2011-12-13 doc cleanups
694 ## Translations and references / hierarchy
695
696 For now, Child, Children, Parent, ReferenceMany, ReferenceOne and Referrers will all fall back to the default language.
697 The reason for this is that there can be only one tracked instance of a document per session. (Otherwise what should happen
698 if both copies where modified?...).
699
36cf7e1c »
2011-12-13 fixing url typo in README
700 For more details, see the [wiki page](https://github.com/doctrine/phpcr-odm/wiki/Multilanguage) and the TODO at the top if this README.
31b8fafb »
2011-12-13 doc cleanups
701
7998ed3a »
2011-12-09 Started writing the translations stuff doc
702 ## Translation API
703
206fd3d9 »
2011-12-12 Added more README and corrected phpDoc in DocumentManager
704 Please refer to the phpDoc of the following functions:
7998ed3a »
2011-12-09 Started writing the translations stuff doc
705
706 __For reading__:
707
31b8fafb »
2011-12-13 doc cleanups
708 * DocumentManager::find (uses the default locale)
709 * DocumentManager::findTranslation (allows you to specify which locale to load)
710 * DocumentManager::getLocalesFor (get the available locales of a document)
7998ed3a »
2011-12-09 Started writing the translations stuff doc
711
712 __For writing__:
713
31b8fafb »
2011-12-13 doc cleanups
714 * DocumentManager::persist (save document in language based on @Locale or default language)
715 * DocumentManager::persitTranslation (save document with explicit language context)
7998ed3a »
2011-12-09 Started writing the translations stuff doc
716
717 ## Example
718
719 ```php
720 <?php
31b8fafb »
2011-12-13 doc cleanups
721
722 // bootstrap the DocumentManager as required (see above)
723
724 $localePrefs = array(
725 'en' => array('en', 'fr'),
726 'fr' => array('fr', 'en'),
727 );
728
206fd3d9 »
2011-12-12 Added more README and corrected phpDoc in DocumentManager
729 $dm = new \Doctrine\ODM\PHPCR\DocumentManager($session, $config);
31b8fafb »
2011-12-13 doc cleanups
730 $dm->setLocaleChooserStrategy(new LocaleChooser($localePrefs, 'en'));
206fd3d9 »
2011-12-12 Added more README and corrected phpDoc in DocumentManager
731
31b8fafb »
2011-12-13 doc cleanups
732 // then to use translations:
206fd3d9 »
2011-12-12 Added more README and corrected phpDoc in DocumentManager
733
734 $doc = new Article();
735 $doc->id = '/my_test_node';
736 $doc->author = 'John Doe';
737 $doc->topic = 'An interesting subject';
738 $doc->text = 'Lorem ipsum...';
739
740 // Persist the document in English
b7c1d591 »
2012-02-01 updated docs to the new API
741 $dm->persist($doc);
742 $dm->bindTranslation($doc, 'en');
206fd3d9 »
2011-12-12 Added more README and corrected phpDoc in DocumentManager
743
744 // Change the content and persist the document in French
b7c1d591 »
2012-02-01 updated docs to the new API
745 $doc->topic = 'Un sujet intéressant';
746 $dm->bindTranslation($doc, 'fr');
206fd3d9 »
2011-12-12 Added more README and corrected phpDoc in DocumentManager
747
db1d491b »
2012-02-03 adjust doc about @Locale annotation (its not mandatory anymore)
748 // locale is updated automatically if there is such an annotation
749 echo $doc->locale; // fr
750
31b8fafb »
2011-12-13 doc cleanups
751 // Flush to write the changes to the phpcr backend
b7c1d591 »
2012-02-01 updated docs to the new API
752 $dm->flush();
206fd3d9 »
2011-12-12 Added more README and corrected phpDoc in DocumentManager
753
31b8fafb »
2011-12-13 doc cleanups
754 // Get the document in default language (English if you bootstrapped as in the example)
b7c1d591 »
2012-02-01 updated docs to the new API
755 $doc = $dm->find('Doctrine\Tests\Models\Translation\Article', '/my_test_node');
206fd3d9 »
2011-12-12 Added more README and corrected phpDoc in DocumentManager
756
757 // Get the document in French
b7c1d591 »
2012-02-01 updated docs to the new API
758 $doc = $dm->findTranslation('Doctrine\Tests\Models\Translation\Article', '/my_test_node', 'fr');
db1d491b »
2012-02-03 adjust doc about @Locale annotation (its not mandatory anymore)
759 $doc->title = 'nouveau';
760 $dm->flush(); // french is updated as the language is tracked by the dm
7998ed3a »
2011-12-09 Started writing the translations stuff doc
761 ```
3151c192 »
2011-04-16 updated readme about multivalue fields
762
f9c8544a »
2012-01-09 fix handling of null fields in translations
763 ## Limitations
764
765 The provided translation strategies will report a translation as not existing
766 if any of the fields declared in the document is not existing. This is a
767 feature because you want to know when you try to load an incomplete document.
768 But we are currently missing a concept how to do update the content to still be
769 compatible when document annotations are changed. The solution could look
db1d491b »
2012-02-03 adjust doc about @Locale annotation (its not mandatory anymore)
770 similar to the ORM migrations concept.
f9c8544a »
2012-01-09 fix handling of null fields in translations
771
772
eb5cbbc9 »
2012-02-01 and we do have doc for versioning too
773 # Versioning documents
774
775 PHPCR-ODM natively supports versioning documents, using the power of the PHPCR
776 Version features. Before you try this out, make sure your implementation
777 supports the versioning features.
778 PHPCR-ODM does not replicate the complete PHPCR Version API (VersionManager,
779 VersionHistory and Version). For the full power, you need to access the PHPCR
780 session and interact with the VersionManager directly.
781 PHPCR-ODM provides simple methods for the common operations.
782
783 ## Concept
784
785 There are 2 levels: simpleVersionable and (full) versionable. Simple versioning
786 consists of a linear verison history and the checkin/checkout possibility.
787 Checking in a node creates a new version and makes the node readonly. You need
788 to check it out again to write to it (or just do a checkpoint to do both in one
789 call).
790 Full versioning additionally has non-linear versioning (which the PHPCR-ODM
791 does not provide any helper methods for) and version labels (which we plan to
792 support once Jackalope supports them). For each node, you can add labels to
793 version, but one label string may only occur once per version history (meaning
794 if you want to label another version, you need to remove the label from the
795 first version before you add the label).
796
797 Version names are generated by PHPCR and can not be controlled by the client
798 application. There is no concept of commit messages for PHPCR. We decided to
799 not build something like that into the core of the ODM versioning system to
800 avoid unnecessary overhead if the user does not need it. It is however doable
801 with having a field on your document that you set to your commit message and
802 flush before calling checkin().
803
804 For more background, read the [Versioning section in the PHPCR Tutorial](https://github.com/phpcr/phpcr/blob/master/doc/Tutorial.md)
805 and refer to the [specification JCR 2.0, Chapter 15](http://www.day.com/specs/jcr/2.0/15_Versioning.html).
806
807 For the PHPCR-ODM layer, the following applies: Contrary to translations,
808 getting an old version does not change the document representing the current
809 version. An old version can't be modified and can't be persisted. (Except with
810 the special restoreVersion and removeVersion methods.)
811 What you get is a detached instance of the document which is ignored by flush
812 and can not be persisted.
813
814
815
816 ## Translation API
817
818 Please refer to the phpDoc of the following functions:
819
820 __Read version information__:
821
822 * DocumentManager::find (returns the current version of the document)
823 * DocumentManager::getAllLinearVersions (returns information about existing versions)
824 * DocumentManager::findVersionByName (returns a detached read-only document representing a version)
825
826 __Modify the version history__:
827
828 * DocumentManager::checkin (create new version of a flushed document and make it readonly)
829 * DocumentManager::checkout (make a document that was checked in writable again)
830 * DocumentManager::checkpoint (create a new version without making the document read-only, aka checkin followed by checkout)
831 * DocumentManager::restoreVersion (restore the document to an old version)
832 * DocumentManager::removeVersion (completely remove an old version from the history)
833
834
835 ## Example
836
837 ```php
838 <?php
839 $article = new Article();
840 $article->id = '/test';
841 $article->topic = 'Test';
842 $dm->persist($article);
843 $dm->flush();
844
96dd7e15 »
2012-02-06 fix mistakes in the versioning example, add more comments
845 // generate a version snapshot of the document as currently stored
eb5cbbc9 »
2012-02-01 and we do have doc for versioning too
846 $dm->checkpoint($article);
847
848 $article->topic = 'Newvalue';
849 $dm->flush();
850
96dd7e15 »
2012-02-06 fix mistakes in the versioning example, add more comments
851 // get the version information
852 $versioninfos = $dm->getAllLinearVersions($article);
eb5cbbc9 »
2012-02-01 and we do have doc for versioning too
853 $firstVersion = reset($versioninfos);
96dd7e15 »
2012-02-06 fix mistakes in the versioning example, add more comments
854 // and use it to find the snapshot of an old version
eb5cbbc9 »
2012-02-01 and we do have doc for versioning too
855 $oldVersion = $dm->findVersionByName(null, $article->id, $firstVersion['name']);
856
857 echo $oldVersion->topic; // "Test"
858
96dd7e15 »
2012-02-06 fix mistakes in the versioning example, add more comments
859 // find the head version
eb5cbbc9 »
2012-02-01 and we do have doc for versioning too
860 $article = $dm->find('/test');
861 echo $article->topic; // "Newvalue"
862
96dd7e15 »
2012-02-06 fix mistakes in the versioning example, add more comments
863 // restore the head to the old version
eb5cbbc9 »
2012-02-01 and we do have doc for versioning too
864 $dm->restoreVersion($oldVersion);
865
866 // the article document is refreshed
867 echo $article->topic; // "Test"
868
96dd7e15 »
2012-02-06 fix mistakes in the versioning example, add more comments
869 // create a second version to demo removing a version
870 $article->topic = 'Newvalue';
871 $dm->flush();
872 $dm->checkpoint($article);
873
874 // remove the old version from the history (not allowed for the last version)
eb5cbbc9 »
2012-02-01 and we do have doc for versioning too
875 $dm->removeVersion($oldVersion);
876 ```
877
878 ## Annotations
879
880 To be able to use the versioning methods of the DocumentManager, you need to
881 specify the versionable attribute in your @Document annotation. You can choose
882 between "full" and "simple" versionable.
883
884 If you only use the methods the DocumentManager offers, "simple" is enough.
885 This will allow you to create a linear version history. The full versionable
886 corresponds to the PHPCR mix:versionable that allows to branch versions. If you
887 need that, you will need to access PHPCR directly for some operations.
888
889 ```php
890 <?php
891 use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM;
892
893 /**
894 * @PHPCRODM\Document(versionable="full")
895 */
896 class Article
897 {
898 ... // properties as normal
899 }
900 ```
901
902 Note that all fields of a document are automatically versioned, you can not
903 exclude anything from being versioned. Referenced documents are not versioned,
904 but it is stored to which document the reference pointed at this time.
905 Children and parents are not versioned. (Actually children could be versioned
906 if you are using a PHCPR node types that specifies to cascade versioning. This
907 feature however is untested with PHPCR-ODM, if you have feedback please tell us.)
908
909
910 You can track some information about old versions in PHPCR-ODM. The VersionName
911 tracks the code that PHPCR assigned the version you created, VersionCreated the
912 timestamp when the version was created.
913
914 Be aware that there are two things:
915 1. The document that is *versionable*. This is **the** document and you can
916 take snapshots of this document with the ``checkin()`` / ``checkpoint()``
917 methods.
918 2. The frozen document that represents an old version of your document. You get
919 this document with the findVersionByName method. It is read-only.
920 The document class you use needs not be the same. You can define a *version*
921 document that is the same as your base document, but all fields are read
922 only and you use the VersionName and VersionCreated annotations on it. It
923 also does not need the versionable document attribute. (You do not create
924 versions of old versions, you only create versions of the main document.)
925
926 ```php
927 <?php
928 /** @PHPCRODM\VersionName */
929 public $versionName;
930
931 /** @PHPCRODM\VersionCreated */
932 public $versionCreated;
933 ```
934
935
84f2472a »
2011-11-23 cleaning up setup and bootstrap documentation in README
936 # Lifecycle callbacks
3151c192 »
2011-04-16 updated readme about multivalue fields
937
b4096b73 »
2011-06-08 changed annotation namespace alias to PHPCRODM
938 You can use @PHPCRODM\PostLoad and friends to have doctrine call a method without
d446b2ff »
2011-05-12 updated readme with information about the Child annotation and the de…
939 parameters on your entity.
db6e4c80 »
2011-04-02 adding some doc about events to the readme
940
941 You can also define event listeners on the DocumentManager with
b7a758e5 »
2011-11-07 Adding GitHub flavored markdown for PHP snippets
942 ```$dm->getEventManager()->addEventListener(array(<events>), listenerclass);```
d446b2ff »
2011-05-12 updated readme with information about the Child annotation and the de…
943 Your class needs event name methods for the events. They get a parameter of type
944 Doctrine\Common\EventArgs.
db6e4c80 »
2011-04-02 adding some doc about events to the readme
945 See also http://www.doctrine-project.org/docs/orm/2.0/en/reference/events.html
946
947 * preRemove - occurs before a document is removed from the storage
948 * postRemove - occurs after the document has been successfully removed
949 * prePersist - occurs before a new document is created in storage
950 * postPersist - occurs after a document has been created in storage. generated ids will be available in this state.
951 * preUpdate - occurs before an existing document is updated in storage, during the flush operation
952 * postUpdate - occurs after an existing document has successfully been updated in storage
953 * postLoad - occurs after the document has been loaded from storage
1207984a »
2012-01-16 fix ProxyFactory to correctly work if auto generate is disabled. fix s…
954
955 # Doc TODOS
956
957 * Explain Configuration class in more detail
958 * Proxy classes: Either configuration with setAutoGenerateProxyClasses(true) or make sure you generate proxies.
959 proxies are used when you have references, children and so on to not load the whole PHPCR repository.
Something went wrong with that request. Please try again.