You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: book/node_types.rst
+64-64
Original file line number
Diff line number
Diff line change
@@ -17,69 +17,7 @@ An Example
17
17
As an example we will define the node types required by a canonical blog
18
18
application.
19
19
20
-
.. configuration-block::
21
-
22
-
.. code-block:: php
23
-
24
-
<?php
25
-
26
-
use PHPCR\NodeType\NodeDefinitionInterface;
27
-
use PHPCR\NodeType\NodeTypeDefinitionInterface;
28
-
use PHPCR\NodeType\PropertyDefinitionInterface;
29
-
30
-
class AcmeBlogNodeType implements NodeTypeDefinitionInterface
31
-
{
32
-
public function getName()
33
-
{
34
-
return 'acmeBlog:blog';
35
-
}
36
-
37
-
public function getDeclaredSupertypeNames()
38
-
{
39
-
return array(
40
-
'nt:base'
41
-
);
42
-
}
43
-
44
-
public function isAbstract()
45
-
{
46
-
return false;
47
-
}
48
-
49
-
public function isMixin()
50
-
{
51
-
return false;
52
-
}
53
-
54
-
public function hasOrderableChildNodes()
55
-
{
56
-
return false;
57
-
}
58
-
59
-
public function isQueryable()
60
-
{
61
-
return false;
62
-
}
63
-
64
-
public function getPrimaryItemName()
65
-
{
66
-
return 'title';
67
-
}
68
-
69
-
public function getDeclaredPropertyDefinitions()
70
-
{
71
-
return array(
72
-
73
-
);
74
-
}
75
-
76
-
public function getDeclaredChildNodeDefinitions()
77
-
{
78
-
return array();
79
-
}
80
-
}
81
-
82
-
.. code-block:: cnd
20
+
.. code-block:: cnd
83
21
84
22
<acmeBlog = "http://example.org/basiccms/ns/1.0">
85
23
@@ -115,6 +53,69 @@ nt:file & nt:folder
115
53
116
54
TODO: List all built-in node types here
117
55
56
+
The Canonical Example
57
+
---------------------
58
+
59
+
This has been copied directly from the `Jackrabbit Node Type Reference <http://jackrabbit.apache.org/node-type-notation.html>`_.
60
+
61
+
.. code-block:: cnd
62
+
63
+
/* An example node type definition */
64
+
65
+
// The namespace declaration
66
+
<ns = 'http://namespace.com/ns'>
67
+
68
+
// Node type name
69
+
[ns:NodeType]
70
+
71
+
// Supertypes
72
+
> ns:ParentType1, ns:ParentType2
73
+
74
+
// This node type supports orderable child nodes
75
+
orderable
76
+
77
+
// This is a mixin node type
78
+
mixin
79
+
80
+
// Nodes of this node type have a property called 'ex:property' of type STRING
81
+
- ex:property (string)
82
+
83
+
// The default values for this
84
+
// (multi-value) property are...
85
+
= 'default1', 'default2'
86
+
87
+
// This property is the primary item
88
+
primary
89
+
90
+
// and it is...
91
+
mandatory autocreated protected
92
+
93
+
// and multi-valued
94
+
multiple
95
+
96
+
// It has an on-parent-version setting of ...
97
+
version
98
+
99
+
// The constraint settings are...
100
+
< 'constraint1', 'constraint2'
101
+
102
+
// Nodes of this node type have a child node called ns:node which must be of
103
+
// at least the node types ns:reqType1 and ns:reqType2
104
+
+ ns:node (ns:reqType1, ns:reqType2)
105
+
106
+
// and the default primary node type of the child node is...
107
+
= ns:defaultType
108
+
109
+
// This child node is...
110
+
mandatory autocreated protected
111
+
112
+
// and supports same name siblings
113
+
multiple
114
+
115
+
// and has an on-parent-version setting of ...
116
+
version
117
+
118
+
118
119
Further Reading
119
120
---------------
120
121
@@ -124,4 +125,3 @@ Further Reading
124
125
* 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.
125
126
126
127
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>`_.
0 commit comments