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

Improved PWF doc #278

Merged
merged 4 commits into from
Oct 1, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
_build/
*.pyc
.idea/
Binary file added _images/bundles/core_pwf_interfaces.dia
Binary file not shown.
Binary file added _images/bundles/core_pwf_interfaces.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _images/bundles/core_pwf_workflow.dia
Binary file not shown.
Binary file added _images/bundles/core_pwf_workflow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
81 changes: 80 additions & 1 deletion bundles/core/publish_workflow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ publication.
A good introduction to the Symfony core security can be found in the
`Security Chapter`_ of the Symfony2 book.


The default publish workflow corresponds to the following diagram:

.. image:: ../../_images/bundles/core_pwf_workflow.png

The return values for ``getPublishStartDate`` and ``getPublishEndDate`` can be ``null``,
in which case the start or end date is unbounded. For example, if the end date
is ``null`` and the start date is ``2013-09-29`` then the object will be
published on the start date and will never be "unpublished".

Check if Content is Published
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

Making Documents Publish Workflow Aware
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The publish workflow component features 4 interfaces:
``PublishableInterface``, ``PublishTimePeriodInterface`` and corresponding
read-only interfaces.

.. image:: ../../_images/bundles/core_pwf_interfaces.png

The read-only interfaces should be used when modifying the information is not
desired.

Below is an example publish workflow implementation::

namespace Acme\BlogBundle\Document;

use Symfony\Cmf\Bundle\CoreBundle\PublishWorkflow\PublishableInterface;
use Symfony\Cmf\Bundle\CoreBundle\PublishWorkflow\PublishTimePeriodInterface;

class Post implements PublishableInterface, PublishTimePeriodInterface
{
// ... properties and methods

/**
* @var \DateTime
*/
protected $publishStartDate;

/**
* @var \DateTime
*/
protected $publishEndDate;

/**
* @var boolean
*/
protected $isPublishable;

public function setPublishStartDate(\DateTime $startDate = null)
{
$this->publishStartDate = $startDate;
}

public function getPublishStartDate()
{
return $this->publishStartDate;
}

public function setPublishEndDate(\DateTime $endDate = null)
{
$this->publishEndDate = $endDate;
}

public function getPublishEndDate()
{
return $this->publishEndDate;
}

public function isPublishable()
{
return $this->isPublishable;
}

public function setIsPublishable($boolean)
{
$this->isPublishable = $boolean;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing yaml, xml and php

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

err, this is a php code example. or you mean we should repeat the code with all the different mapping types? for the others, would you simply show the mapping but not the class?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is just an illustration of one of many different scenarios, I think its OK as is. As explained I only did the PHPCR-ODM annotations to help illustrate a common use case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meaned different mapping types, as you can see in the doc standards: http://symfony.com/doc/current/contributing/documentation/standards.html#formats

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall I remove the annotations and replace them with @var DateTime then ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that would get you rid of the disclaimers about PHPCR-ODM and reduce the example to what you actually want to show. so +1

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1


Publish Voters
~~~~~~~~~~~~~~

Expand Down Expand Up @@ -253,7 +332,7 @@ you can lower the priority of those voters.

The workflow checker will create an
:class:`Symfony\\Component\\Security\\Core\\Authentication\\Token\\AnonymousToken` on
the fly if the securty context has none. This means that voters must be able
the fly if the security context has none. This means that voters must be able
to handle this situation when accessing the user. Also when accessing the
security context, they first must check if it has a token and otherwise they
should not call it to avoid triggering an exception. If a voter only gives
Expand Down