PublishableBehavior
, (*1)
The PublishableBehavior is designed to quickly add publish/unpublish features to your model., (*2)
Installation
Install the behavior in your project, the recommended way is to use Composer:, (*3)
``` json
{
"require": {
"willdurand/propel-publishable-behavior": "dev-master"
}
}, (*4)
Add the following line to your `propel.ini` or `build.properties` configuration file:
``` ini
propel.behavior.publishable.class = vendor.willdurand.propel-publishable-behavior.src.PublishableBehavior
Note: vendor.willdurand.propel-publishable-behavior.src
is the path of the behavior in dot-path notation., (*5)
Usage
ActiveRecord API
Returns true if the object is published, false otherwise:, (*6)
isPublished()
Mark an object as published:, (*7)
publish(PropelPDO $con = null)
Mark an object as not published:, (*8)
unpublish(PropelPDO $con = null)
Has publication frame started ?, (*9)
hasPublicationEnded()
Has publication frame started ?, (*10)
hasPublicationStarted()
ActiveQuery API
Include unpublished objects in the results set:, (*11)
includeUnpublished()
Filter by objects not published exclusively:, (*12)
filterUnpublished()
Filter by objects published exclusively:, (*13)
filterPublished()
Filter by publication active, (*14)
filterByPublicationActive($date = 'now')
Mark an object as published:, (*15)
publish(PropelPDO $con = null)
Mark an object as not published:, (*16)
unpublish(PropelPDO $con = null)
Parameters
``` xml
, (*17)
> Note: Parameter `include_unpublished` allows you to exclude unpublished object from each query. It is setup to `false` by default. If you don't want to exclude unpublished items, you have to set it to `true`
Running tests
-------------
First of all, copy the `phpunit.xml.dist` to `phpunit.xml`.
If you did not install propel with composer, change `PROPEL_DIR` and `PHING_DIR`
values to customize the include path.
Customize autoloader by changing `AUTOLOAD` property.
then simply launch
``` bash
$ vendor/bin/phpunit -c phpunit.xml
All green?, (*18)
Credits