\Charcoal\ObjectPublishableTrait

A full implementation, as trait, of the `PublishableInterface`.

Summary

Methods
Properties
Constants
setPublishDate()
publishDate()
setExpiryDate()
expiryDate()
setPublishStatus()
publishStatus()
isPublished()
No public properties found
No constants found
No protected methods found
$publishDate
$expiryDate
$publishStatus
N/A
publishDateStatus()
No private properties found
N/A

Properties

$publishDate

$publishDate : \DateTimeInterface

Type

\DateTimeInterface

$expiryDate

$expiryDate : \DateTimeInterface

Type

\DateTimeInterface

$publishStatus

$publishStatus : string

Type

string

Methods

setPublishDate()

setPublishDate(string|\DateTimeInterface|null  $publishDate) : \Charcoal\Object\PublishableInterface

Parameters

string|\DateTimeInterface|null $publishDate

The publishing date.

Throws

\InvalidArgumentException

If the date/time is invalid.

Returns

\Charcoal\Object\PublishableInterface

Chainable

publishDate()

publishDate() : \DateTimeInterface|null

Returns

\DateTimeInterface|null

setExpiryDate()

setExpiryDate(string|\DateTimeInterface|null  $expiryDate) : \Charcoal\Object\PublishableInterface

Parameters

string|\DateTimeInterface|null $expiryDate

The expiry date.

Throws

\InvalidArgumentException

If the date/time is invalid.

Returns

\Charcoal\Object\PublishableInterface

Chainable

expiryDate()

expiryDate() : \DateTimeInterface|null

Returns

\DateTimeInterface|null

setPublishStatus()

setPublishStatus(string  $status) : \Charcoal\Object\PublishableInterface

Parameters

string $status

The publish status (draft, pending or published).

Throws

\InvalidArgumentException

If the status is not one of the 3 valid status.

Returns

\Charcoal\Object\PublishableInterface

Chainable

publishStatus()

publishStatus() : string

Get the object's publish status.

Status can be:

  • draft
  • pending
  • published
  • upcoming
  • expired

Note that the upcoming and expired status are specialized status when the object is set to published but the publishDate or expiryDate do not match.

Returns

string

isPublished()

isPublished() : boolean

Returns

boolean

publishDateStatus()

publishDateStatus() : string

Get the "publish status" from the publish date / expiry date.

  • If no publish date is set, then it is assumed to be "always published." (or expired)
  • If no expiry date is set, then it is assumed to never expire.

Returns

string