@@ -8,7 +8,7 @@ Path providers specify a target path which is used by the subsequent path
8
8
actions to provide the actual route documents.
9
9
10
10
**Base ** providers must be the first configured as the first builder in the
11
- content path chain. This is because the paths that they provide correspond
11
+ content path chain. This is because the paths that they provide correspond
12
12
directly to an existing path, i.e. they have an absolute reference.
13
13
14
14
specified (base provider)
@@ -17,6 +17,14 @@ specified (base provider)
17
17
This is the most basic path provider and allows you to specify an exact
18
18
(fixed) path.
19
19
20
+ Options
21
+ .......
22
+
23
+ * ``path `` - **required ** The path to provide.
24
+
25
+ Example
26
+ .......
27
+
20
28
.. configuration-block ::
21
29
22
30
.. code-block :: yaml
@@ -36,68 +44,73 @@ This is the most basic path provider and allows you to specify an exact
36
44
'provider' => array('specified', array('path' => 'this/is/a/path')),
37
45
);
38
46
39
- Options :
47
+ .. caution : :
40
48
41
- * ``path `` - **required ** The path to provide.
42
-
43
- .. note ::
44
-
45
- You never specifiy absolute paths in the auto route system. If the builder
46
- unit is the first content path chain it is understood that it is the base
47
- of an absolute path.
49
+ You should never specifiy absolute paths in the auto route system. If the
50
+ builder unit is the first content path chain it is understood that it is
51
+ the base of an absolute path.
48
52
49
53
content_object (base provider)
50
54
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
51
55
52
56
The content object provider will try and provide a path from an object
53
57
implementing ``RouteReferrersInterface `` provided by a designated method on the
54
- content document. For example, if you have a ``Post `` class, which has a
55
- ``getBlog `` method, using this provider you can tell the ``Post `` auto route
56
- to use the route of the blog as a base.
58
+ content document. For example, if you have a ``Topic `` class, which has a
59
+ ``getCategory `` method, using this provider you can tell the ``Topic `` auto route
60
+ to use the route of the category as a base.
61
+
62
+ So basically, if your category document has a path of ``/this/is/my/category ``,
63
+ you can use this path as the base of your ``Category `` auto-route.
57
64
58
- So basically, if your blog content has a path of `` /this/is/my/blog `` you can
59
- use this path as the base of your `` Post `` auto-route .
65
+ Options
66
+ ...... .
60
67
61
- Example:
68
+ - ``method ``: **required ** Method used to return the document whose route path you wish to use.
69
+
70
+ Example
71
+ .......
62
72
63
73
.. configuration-block ::
64
74
65
75
.. code-block :: yaml
66
76
67
- provider : [content_object, { method: getBlog }]
77
+ provider : [content_object, { method: getCategory }]
68
78
69
79
.. code-block :: xml
70
80
71
81
<provider name =" content_object" >
72
- <option name =" method" value =" getBlog " />
82
+ <option name =" method" value =" getCategory " />
73
83
</provider >
74
84
75
85
.. code-block :: php
76
86
77
87
array(
78
88
// ...
79
- 'provider' => array('content_object', array('method' => 'getBlog ')),
89
+ 'provider' => array('content_object', array('method' => 'getCategory ')),
80
90
);
81
91
82
92
.. note ::
83
93
84
- At the time of writing translated objects are not supported. This isn't hard to do, but well, I just
85
- havn't done it yet.
86
-
87
- Options:
88
-
89
- - ``method ``: **required ** Method used to return the document whose route path we wish to use.
94
+ At the time of writing translated objects are not supported. But a patch
95
+ is already created for this feature.
90
96
91
97
content_method
92
98
~~~~~~~~~~~~~~
93
99
94
- The ``content_method `` provider allows the content object (e.g. a blog
95
- ``Post ``) to specify a path using one of its methods. This is quite a powerful
100
+ The ``content_method `` provider allows the content object (e.g. a forum
101
+ ``Topic ``) to specify a path using one of its methods. This is quite a powerful
96
102
method as it allows the content document to do whatever it can to produce the
97
103
route, the disadvantage is that your content document will have extra code in
98
104
it.
99
105
100
- **Example 1 **:
106
+ Options
107
+ .......
108
+
109
+ * ``method ``: **required ** Method used to return the route name/path/path elements.
110
+ * ``slugify ``: If the return value should be slugified, default is ``true ``.
111
+
112
+ Example
113
+ .......
101
114
102
115
.. configuration-block ::
103
116
@@ -118,58 +131,44 @@ it.
118
131
'provider' => array('content_method', array('method' => 'getTitle')),
119
132
);
120
133
121
- This example will use the existing method "getTitle" of the ``Post `` document
134
+ This example will use the existing method "getTitle" of the ``Topic `` document
122
135
to retrieve the title. By default all strings are *slugified *.
123
136
124
- The method can return the path either as a single string or an array of path
125
- elements as shown in the following example::
137
+ The method can return the path either as a single string, an array of path
138
+ elements or an object which can be converted into a string, as shown in the
139
+ following example::
126
140
127
- class Post
141
+ class Topic
128
142
{
129
- public function getTitle()
130
- {
131
- return "This is a post";
132
- }
133
-
134
- public function getPathElements()
135
- {
136
- return array('this', 'is', 'a', 'path');
137
- }
143
+ /* Using a string */
144
+ public function getTitle()
145
+ {
146
+ return "This is a topic";
147
+ }
148
+
149
+ /* Using an array */
150
+ public function getPathElements()
151
+ {
152
+ return array('this', 'is', 'a', 'path');
153
+ }
154
+
155
+ /* Using an object */
156
+ public function getStringObject()
157
+ {
158
+ $object = ...; // an object which has a __toString() method
159
+
160
+ return $object;
161
+ }
138
162
}
139
163
140
- Options:
141
-
142
- * ``method ``: **required ** Method used to return the route name/path/path elements.
143
- * ``slugify ``: If we should use the slugifier, default is ``true ``.
144
-
145
164
content_datetime
146
165
~~~~~~~~~~~~~~~~
147
166
148
167
The ``content_datettime `` provider will provide a path from a ``DateTime ``
149
168
object provided by a designated method on the content document.
150
169
151
- **Example 1 **:
152
-
153
- .. configuration-block ::
154
-
155
- .. code-block :: yaml
156
-
157
- provider : [content_datetime, { method: getDate }]
158
-
159
- .. code-block :: xml
160
-
161
- <provider name =" content_datetime" >
162
- <option name =" method" value =" getDate" />
163
- </provider >
164
-
165
- .. code-block :: php
166
-
167
- array(
168
- // ...
169
- 'provider' => array('content_datetime', array('method' => 'getDate')),
170
- );
171
-
172
- **Example 2 **:
170
+ Example
171
+ .......
173
172
174
173
.. configuration-block ::
175
174
@@ -196,17 +195,18 @@ object provided by a designated method on the content document.
196
195
197
196
.. note ::
198
197
199
- This method extends `content_method ` and inherits the slugify feature.
200
- Internally we return a string using the `DateTime->format() ` method. This
198
+ This method extends `content_method `_ and inherits the slugify feature.
199
+ Internally, it returns a string using the `DateTime->format() ` method. This
201
200
means that you can specify your date in anyway you like and it will be
202
- automatically slugified, also , by adding path separators in the
203
- `date_format ` you are effectively creating routes for each date component
201
+ automatically slugified. Also , by adding path separators in the
202
+ `` date_format ` ` you are effectively creating routes for each date component
204
203
as slugify applies to **each element ** of the path.
205
204
206
- Options:
205
+ Options
206
+ .......
207
207
208
208
* ``method ``: **required ** Method used to return the route name/path/path
209
209
elements.
210
- * ``slugify ``: If we should use the slugifier , default is ``true ``.
210
+ * ``slugify ``: If the return value should be slugified , default is ``true ``.
211
211
* ``date_format ``: Any date format accepted by the `DateTime ` class, default
212
212
``Y-m-d ``.
0 commit comments