@@ -22,6 +22,16 @@ publication.
22
22
A good introduction to the Symfony core security can be found in the
23
23
`Security Chapter `_ of the Symfony2 book.
24
24
25
+
26
+ The default publish workflow corresponds to the following diagram:
27
+
28
+ .. image :: ../../_images/bundles/core_pwf_workflow.png
29
+
30
+ The return values for ``getPublishStartDate `` and ``getPublishEndDate `` can be ``null ``,
31
+ in which case the start or end date is unbounded. For example, if the end date
32
+ is ``null `` and the start date is ``2013-09-29 `` then the object will be
33
+ published on the start date and will never be "unpublished".
34
+
25
35
Check if Content is Published
26
36
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27
37
@@ -166,6 +176,75 @@ the content to be considered not published. If all voters abstain (for example
166
176
when the content in question does not implement any workflow features) the
167
177
content is still considered published.
168
178
179
+ Making Documents Publish Workflow Aware
180
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
181
+
182
+ The publish workflow component features 4 interfaces:
183
+ ``PublishableInterface ``, ``PublishTimePeriodInterface `` and corresponding
184
+ read-only interfaces.
185
+
186
+ .. image :: ../../_images/bundles/core_pwf_interfaces.png
187
+
188
+ The read-only interfaces should be used when modifying the information is not
189
+ desired.
190
+
191
+ Below is an example publish workflow implementation::
192
+
193
+ namespace Acme\BlogBundle\Document;
194
+
195
+ use Symfony\Cmf\Bundle\CoreBundle\PublishWorkflow\PublishableInterface;
196
+ use Symfony\Cmf\Bundle\CoreBundle\PublishWorkflow\PublishTimePeriodInterface;
197
+
198
+ class Post implements PublishableInterface, PublishTimePeriodInterface
199
+ {
200
+ // ... properties and methods
201
+
202
+ /**
203
+ * @var \DateTime
204
+ */
205
+ protected $publishStartDate;
206
+
207
+ /**
208
+ * @var \DateTime
209
+ */
210
+ protected $publishEndDate;
211
+
212
+ /**
213
+ * @var boolean
214
+ */
215
+ protected $isPublishable;
216
+
217
+ public function setPublishStartDate(\DateTime $startDate = null)
218
+ {
219
+ $this->publishStartDate = $startDate;
220
+ }
221
+
222
+ public function getPublishStartDate()
223
+ {
224
+ return $this->publishStartDate;
225
+ }
226
+
227
+ public function setPublishEndDate(\DateTime $endDate = null)
228
+ {
229
+ $this->publishEndDate = $endDate;
230
+ }
231
+
232
+ public function getPublishEndDate()
233
+ {
234
+ return $this->publishEndDate;
235
+ }
236
+
237
+ public function isPublishable()
238
+ {
239
+ return $this->isPublishable;
240
+ }
241
+
242
+ public function setIsPublishable($boolean)
243
+ {
244
+ $this->isPublishable = $boolean;
245
+ }
246
+ }
247
+
169
248
Publish Voters
170
249
~~~~~~~~~~~~~~
171
250
@@ -253,7 +332,7 @@ you can lower the priority of those voters.
253
332
254
333
The workflow checker will create an
255
334
:class: `Symfony\\ Component\\ Security\\ Core\\ Authentication\\ Token\\ AnonymousToken ` on
256
- the fly if the securty context has none. This means that voters must be able
335
+ the fly if the security context has none. This means that voters must be able
257
336
to handle this situation when accessing the user. Also when accessing the
258
337
security context, they first must check if it has a token and otherwise they
259
338
should not call it to avoid triggering an exception. If a voter only gives
0 commit comments