Skip to content

Commit 376fe11

Browse files
committed
Updated #2
1 parent cd3453b commit 376fe11

13 files changed

+89
-50
lines changed

Diff for: book/conclusion.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Conclusion and further reading
22
==============================
33

4-
We hope this tutorial helps to get you started. If you miss anything, have suggestions or questions, please contact us on [email protected] or #jackalope on irc.freenode.net
4+
We hope this guide helps to get you started. If you miss anything, have suggestions or questions, please contact us on [email protected] or #jackalope on irc.freenode.net
55

66
Further reading
77
---------------

Diff for: book/getting_started.rst

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Getting Stated
33

44
This aims to provide a rounded general reference to PHPCR. You will mostly see
55
code examples. It should work with any PHPCR implementation. We propose using
6-
[Jackalope Jackrabbit](https://github.com/jackalope/jackalope-jackrabbit) to
6+
`Jackalope Jackrabbit <https://github.com/jackalope/jackalope-jackrabbit>`_ to
77
get started as it supports all features described here.
88

99
Installing Jackalope
@@ -76,7 +76,8 @@ Still with us? Good, lets get in a bit deeper...
7676
Get some data into the repository
7777
---------------------------------
7878

79-
We will discuss the import feature in more detail later, but to have some data, we just import something here. Create an XML file called `test.xml`:
79+
We will discuss the import feature in more detail later, but to have some
80+
data, we just import something here. Create an XML file called `test.xml``:
8081

8182
.. code-block:: xml
8283
@@ -104,4 +105,4 @@ You may also use the PHPCR Shell to import data:
104105

105106
.. code-block:: bash
106107
107-
$ phpcrsh -pmyprofile -c "session:import-xml test.xml"
108+
phpcrsh -pmyprofile -c "session:import-xml test.xml"

Diff for: book/import_export.rst

+7-6
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ are two formats:
1111
of the repository with all type information. However, it is more verbose.
1212

1313
As an analogy, think about an SQL dump file with SQL statements and the dump of
14-
an SQL table into a csv file. You can restore the data from both, but the SQL
14+
an SQL table into a ``csv`` file. You can restore the data from both, but the SQL
1515
dump knows every detail about your field types and so on while the CSV just
1616
knows the data.
1717

18-
When exporting, you tell explicitly to which format you want to export:
18+
When exporting, you explictly call a method corresponding to the desired
19+
format:
1920

2021
.. code-block:: php
2122
@@ -60,7 +61,7 @@ valid XML document it is imported as document:
6061
6162
When importing nodes with a uuid, a couple of different behaviors can be used:
6263

63-
* `IMPORT_UUID_CREATE_NEW`: Create new UUIDs for nodes that are imported, so you never get collisions.
64-
* `IMPORT_UUID_COLLISION_THROW`: Throw an exception if a node with the same UUID already exists.
65-
* `IMPORT_UUID_COLLISION_REMOVE_EXISTING`: Remove an existing node if an imported node has the same UUID.
66-
* `IMPORT_UUID_COLLISION_REPLACE_EXISTING`: Replace existing node with the imported node. This can lead to the imported data being put in various places.
64+
* ``IMPORT_UUID_CREATE_NEW``: Create new UUIDs for nodes that are imported, so you never get collisions.
65+
* ``IMPORT_UUID_COLLISION_THROW``: Throw an exception if a node with the same UUID already exists.
66+
* ``IMPORT_UUID_COLLISION_REMOVE_EXISTING``: Remove an existing node if an imported node has the same UUID.
67+
* ``IMPORT_UUID_COLLISION_REPLACE_EXISTING``: Replace existing node with the imported node. This can lead to the imported data being put in various places.

Diff for: book/introduction.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Introduction
33

44
In the following chapters, we will show how to use the API. But first, you
55
need a very brief overview of the core elements of PHPCR. After reading this
6-
tutorial, you should browse through the API documentation to get an idea what
6+
guide, you should browse through the API documentation to get an idea what
77
operations you can do on each of those elements. See the conclusions for links
88
if you want to have more background.
99

Diff for: book/locking.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
Locking
22
=======
33

4-
In PHPCR, you can lock nodes to prevent concurrency issues. There is two basic types of locks:
4+
In PHPCR, you can lock nodes to prevent concurrency issues. There are two basic types of locks:
55

66
* Session based locks are only kept until your session ends and released automatically on logout.
77
* If a lock is not session based, it is identified by a lock token and stays in place until it times out
88

9-
Note that jackalope currently only implements session based locks:
9+
Note that Jackalope currently only implements session based locks:
1010

1111
.. code-block:: php
1212

Diff for: book/node_types.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ PHPCR supports node types. Node types define what properties and children a node
55

66
In a nutshell:
77

8-
* `nt:unstructured` does not define any required properties but allows any property or child.
9-
* `nt:file` and `nt:folder` are built-in node types useful to map a file structure in the repository. (With jackalope-jackrabbit, files and folders are exposed over webdav)
8+
* ``nt:unstructured`` does not define any required properties but allows any property or child.
9+
* ``nt:file`` and ``nt:folder`` are built-in node types useful to map a file structure in the repository. (With jackalope-jackrabbit, files and folders are exposed over webdav)
1010
* If you **do not** want to enforce a schema on your node, use
11-
`nt:unstructured`.
11+
``nt:unstructured``.
1212
* If you need to store additional properties or children on existing node types like files, note that while a node can have only one primary type, every node can have any mixin types. Define a mixin type declaring your additional properties, register it with PHPCR and addMixin it to the nodes that need it.
1313

1414
You can define your own node types if you want the equivalent of a strictly defined database structure. See `JCR 2.0: 3.7 Node Types <http://www.day.com/specs/jcr/2.0/3_Repository_Model.html#3.7%20Node%20Types>`_ and `JCR 2.0: 19 Node Type Management <http://www.day.com/specs/jcr/2.0/19_Node_Type_Management.html>`_ / `PHPCR Node Type Namespace <http://phpcr.github.io/doc/html/index.html>`_.

Diff for: book/performance.rst

+34-12
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,49 @@
11
Performance considerations
22
==========================
33

4-
While PHPCR can perform reasonably well, you should be careful. You are working with an object model mapping interlinked data. Implementations are supposed to lazy load data only when necessary. But you should take care to only request what you actually need.
4+
While PHPCR can perform reasonably well, you should be careful. You are
5+
working with an object model mapping interlinked data. Implementations are
6+
supposed to lazy load data only when necessary. But you should take care to
7+
only request what you actually need.
58

6-
The implementations will also use some sort of storage backend (Jackrabbit, (no)SQL database, ...). There might be a huge performance impact in configuring that storage backend optimally. Look into your implementation documentation if there are recommendations how to optimize storage.
7-
8-
One thing *not* to worry about is requesting the same node with Session::getNode or Node::getNode/s several times. You always get the same object instance back without overhead.
9+
The implementations will also use some sort of storage backend (Jackrabbit,
10+
(no)SQL database, ...). There might be a huge performance impact in
11+
configuring that storage backend optimally. Look into your implementation
12+
documentation if there are recommendations how to optimize storage.
913

14+
One thing *not* to worry about is requesting the same node with
15+
Session::getNode or Node::getNode/s several times. You always get the same
16+
object instance back without overhead.
1017

1118
Only request what you need
1219
--------------------------
1320

14-
emember that you can filter nodes on Node::getNodes if you only need a list of specific nodes or all nodes in some namespace.
15-
16-
The values of binary properties can potentially have a huge size and should only loaded when really needed. If you just need the size, you can get the property instance and do a $property->getSize() instead of filesize($node->getPropertyValue). Any decent implementation will not preload the binary stream when you access the property object.
17-
18-
When getting the properties from a node, you can use Node::getPropertiesValues(filter, false). This allows the implementation to avoid instantiating Property objects for the property values (and saves you coding). The second boolean parameter tells wheter to dereference reference properties. If you do not need the referenced objects, pass false and you will get the UUID or path strings instead of node objects.(If you need one of them, you can still get it with Session::getNodeByIdentifier. But then the implementation will certainly not be able to optimize if you get several referenced nodes.)
19-
21+
emember that you can filter nodes on Node::getNodes if you only need a list of
22+
specific nodes or all nodes in some namespace.
23+
24+
The values of binary properties can potentially have a huge size and should
25+
only loaded when really needed. If you just need the size, you can get the
26+
property instance and do a $property->getSize() instead of
27+
filesize($node->getPropertyValue). Any decent implementation will not preload
28+
the binary stream when you access the property object.
29+
30+
When getting the properties from a node, you can use
31+
Node::getPropertiesValues(filter, false). This allows the implementation to
32+
avoid instantiating Property objects for the property values (and saves you
33+
coding). The second boolean parameter tells wheter to dereference reference
34+
properties. If you do not need the referenced objects, pass false and you will
35+
get the UUID or path strings instead of node objects.(If you need one of them,
36+
you can still get it with Session::getNodeByIdentifier. But then the
37+
implementation will certainly not be able to optimize if you get several
38+
referenced nodes.)
2039

2140
But request in one call as much as possible of what you need
2241
------------------------------------------------------------
2342

24-
If you need to get several nodes where you know the paths, use Session::getNodes with an array of those nodes to get all of them in one batch, saving round trip time to the storage backend.
43+
If you need to get several nodes where you know the paths, use
44+
``Session::getNodes`` with an array of those nodes to get all of them in one
45+
batch, saving round trip time to the storage backend.
2546

26-
lso use Node::getNodes with a list of nodes rather than repeatedly calling Node::getNode.
47+
You can also use ``Node::getNodes`` with a list of nodes rather than repeatedly calling
48+
``Node::getNode``.
2749

Diff for: book/query.rst

+12-12
Original file line numberDiff line numberDiff line change
@@ -53,29 +53,29 @@ You can access the QueryObjectModelFactory from the session:
5353
<?php
5454
$qomFactory = $mySession->getWorkspace()->getQueryManager()->getQOMFactory();
5555
56-
The QOM factory has a method to build a QOM query given four parameters, and [provides methods](http://phpcr.github.com/doc/html/phpcr/query/qom/queryobjectmodelfactoryinterface.html) to build these four parameters:
56+
The QOM factory has a method to build a QOM query given four parameters, and `provides methods <http://phpcr.github.com/doc/html/phpcr/query/qom/queryobjectmodelfactoryinterface.html>`_ to build these four parameters:
5757

5858
.. code-block:: php
5959
6060
<?php
6161
$queryObjectModel = $QOMFactory->createQuery(SourceInterface source, ConstraintInterface constraint, array orderings, array columns);
6262
63-
`source` is made out of one or more selectors. Each selector selects a subset of nodes. Queries with more than one selector have joins. A query with two selectors will have a join, a query with three selectors will have two joins, and so on.
63+
- ``source`` is made out of one or more selectors. Each selector selects a subset of nodes. Queries with more than one selector have joins. A query with two selectors will have a join, a query with three selectors will have two joins, and so on.
6464

65-
`constraint` filters the set of node-tuples to be retrieved. Constraint may be combined in a tree of constraints to perform a more complex filtering. Examples of constraints are:
65+
``constraint`` filters the set of node-tuples to be retrieved. Constraint may be combined in a tree of constraints to perform a more complex filtering. Examples of constraints are:
6666

67-
* Absolute or relative paths: nodes descendant of a path, nodes children of a path, nodes reachable by a path.
68-
* Name of the node.
69-
* Value of a property.
70-
* Length of a property.
71-
* Existence of a property.
72-
* Full text search.
67+
- Absolute or relative paths: nodes descendant of a path, nodes children of a path, nodes reachable by a path.
68+
- Name of the node.
69+
- Value of a property.
70+
- Length of a property.
71+
- Existence of a property.
72+
- Full text search.
7373

74-
`orderings` determine the order in which the filtered node-tuples will appear in the query results. The relative order of two node-tuples is determined by evaluating the specified orderings, in list order, until encountering an ordering for which one node-tuple precedes the other.
74+
- ``orderings`` determine the order in which the filtered node-tuples will appear in the query results. The relative order of two node-tuples is determined by evaluating the specified orderings, in list order, until encountering an ordering for which one node-tuple precedes the other.
7575

76-
`columns` are the columns to be included in the tabular view of query results. If no columns are specified, the columns available in the tabular view are implementation determined. In Jackalope include, for each selector, a column for each single-valued non-residual property of the selector's node type.
76+
- ``columns`` are the columns to be included in the tabular view of query results. If no columns are specified, the columns available in the tabular view are implementation determined. In Jackalope include, for each selector, a column for each single-valued non-residual property of the selector's node type.
7777

78-
The simplest case is to select all `[nt:unstructured]` nodes:
78+
The simplest case is to select all ``[nt:unstructured]`` nodes:
7979

8080
.. code-block:: php
8181

Diff for: book/reading_data_and_traversal.rst

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
Reading data and traversal
22
==========================
33

4-
You can wrap any code into try catch blocks. See the `API doc <http://phpcr.github.com/doc/html/index.html>`_ for what exceptions to expect on which calls. With PHPCR being ported from Java, there is a lot of Exceptions defined.
5-
But as this is PHP, you don't have to catch them. As long as your content is as the code expects, it won't matter.
4+
You can wrap any code into try catch blocks. See the `API doc
5+
<http://phpcr.github.com/doc/html/index.html>`_ for what exceptions to expect
6+
on which calls. With PHPCR being ported from Java, there is a lot of
7+
Exceptions defined. But as this is PHP, you don't have to catch them. As long
8+
as your content is as the code expects, it won't matter.
69

710
.. code-block:: php
811
@@ -107,4 +110,3 @@ Traversing the hierarchy
107110
} while ($parent != $node);
108111
var_dump($breadcrumb);
109112
110-

Diff for: book/references.rst

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
Node and property references
22
============================
33

4-
Nodes can be referenced by unique id (if they are mix:referenceable) or by path. getValue returns the referenced node instance.
5-
Properties can only be referenced by path because they can not have a unique id.
4+
Nodes can be referenced by unique id (if they are mix:referenceable) or by
5+
path. getValue returns the referenced node instance. Properties can only be
6+
referenced by path because they can not have a unique id.
67

78
The test document we imported above does not contain the type information we
8-
need to show this example. Lets create a special one and load it into the repository with Session::importXML:
9+
need to show this example. Lets create a special one and load it into the
10+
repository with ``Session::importXML``:
911

1012
.. code-block:: xml
1113

Diff for: book/search.rst

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,12 @@ Search
33

44
TODO: intelligent filtering criteria to do as little in-memory operations to apply criteria.
55

6-
If you do not need the node objects but just some value, query for that value and use the result Row to avoid instantiating Node objects alltogether. If you need the Node objects, help PHPCR to optimize by using QueryResult::getNodes and iterating over the nodes instead of getting the rows, iterating over them and calling getNode on each row. (Actually, if you first do the getNodes(), you can then iterate over the rows and get the individual nodes and still use the special row methods as the implementation should have prefetched data on the getNodes.)
6+
If you do not need the node objects but just some value, query for that value
7+
and use the result Row to avoid instantiating Node objects alltogether. If you
8+
need the Node objects, help PHPCR to optimize by using QueryResult::getNodes
9+
and iterating over the nodes instead of getting the rows, iterating over them
10+
and calling getNode on each row. (Actually, if you first do the getNodes(),
11+
you can then iterate over the rows and get the individual nodes and still use
12+
the special row methods as the implementation should have prefetched data on
13+
the getNodes.)
714

Diff for: book/versioning.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
Versioning
22
==========
33

4-
Versioning is used to track changes in nodes with the possibility to get back to older versions.
4+
Versioning is used to track changes in nodes with the possibility to get back
5+
to older versions.
56

67
A node with the mixin type `mix:versionable` or `mix:simpleVersionable` can be
78
versioned. Versioned nodes have a version history, containing the root version

Diff for: book/writing.rst

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ Writing data
44
Creating and updating nodes
55
---------------------------
66

7-
With PHPCR, you never use 'new'. The node works as a factory to create new nodes and properties. This has the nice side effect that you can not add a node where there is no parent.
7+
With PHPCR, you never use 'new'. The node works as a factory to create new
8+
nodes and properties. This has the nice side effect that you can not add a
9+
node where there is no parent.
810

9-
Everything you do on the Session, Node and Property objects is only visible locally in this session until you save the session.
11+
Everything you do on the Session, Node and Property objects is only visible
12+
locally in this session until you save the session.
1013

1114
.. code-block:: php
1215

0 commit comments

Comments
 (0)