Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit 576a99b

Browse files
committed
Merge pull request #278 from symfony-cmf/core_pwf
Improved PWF doc
2 parents 1b5deff + 0efbe43 commit 576a99b

File tree

6 files changed

+80
-2
lines changed

6 files changed

+80
-2
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
_build/
22
*.pyc
3-
.idea/
1.73 KB
Binary file not shown.
12 KB
Loading

_images/bundles/core_pwf_workflow.dia

2.19 KB
Binary file not shown.

_images/bundles/core_pwf_workflow.png

53.9 KB
Loading

bundles/core/publish_workflow.rst

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ publication.
2222
A good introduction to the Symfony core security can be found in the
2323
`Security Chapter`_ of the Symfony2 book.
2424

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+
2535
Check if Content is Published
2636
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2737

@@ -166,6 +176,75 @@ the content to be considered not published. If all voters abstain (for example
166176
when the content in question does not implement any workflow features) the
167177
content is still considered published.
168178

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+
169248
Publish Voters
170249
~~~~~~~~~~~~~~
171250

@@ -253,7 +332,7 @@ you can lower the priority of those voters.
253332
254333
The workflow checker will create an
255334
: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
257336
to handle this situation when accessing the user. Also when accessing the
258337
security context, they first must check if it has a token and otherwise they
259338
should not call it to avoid triggering an exception. If a voter only gives

0 commit comments

Comments
 (0)