Table of Contents

ScheduledPostService

Layer: Service · Source: lib/service/ScheduledPostService.php:25 (lines 25–156)


class ScheduledPostService

Promotes posts with the 'scheduled' status whose post_date has passed, using a lightweight per-request flip (WordPress-style “poor man's cron”).

Docblock Metadata

Tag Value
@category Service Class
@author Scriptlog
@license MIT
@version 1.0
@since Since Release 1.0

Inheritance

No parent, interface or trait. This is a root type.

Constants (2)

Visibility Name Value Line
private ENABLED_SETTING 'writing_scheduled_post_enabled'; 32
private NEXT_RUN_SETTING 'writing_scheduled_next_run'; 39

Properties (3)

Visibility Type Name Default Line
private (untyped) $postDao 46
private (untyped) $configDao 53
private (untyped) $sanitize 60

Methods (5)

Visibility Method Summary Line
public __construct() Constructor. 69
public isEnabled() Check whether scheduled posting is enabled globally. 84
public getNextRun() Get the earliest scheduled post_date (next-run shortcut). 100
public setNextRun() Persist the next-run shortcut. 115
public publishDuePosts() Publish every scheduled post whose post_date has passed. 138

__construct()

public function __construct(PostDao $postDao, ConfigurationDao $configDao, Sanitize $sanitize)

lines 69–74 (6)

Constructor.

Parameter Type Default Description
$postDao ''PostDao'' required none
$configDao ''ConfigurationDao'' required none
$sanitize ''Sanitize'' required none

isEnabled()

public function isEnabled(): bool

lines 84–93 (10)

Check whether scheduled posting is enabled globally.

Defaults to enabled when the setting row is missing (fresh installs and existing blogs before the Writing settings page is first saved).

Takes no parameters.

Returns: bool — bool

getNextRun()

public function getNextRun(): ?string

lines 100–107 (8)

Get the earliest scheduled post_date (next-run shortcut).

Takes no parameters.

Returns: ?string — string|null Next run datetime ('Y-m-d H:i:s'), or null when unset

setNextRun()

public function setNextRun(?string $when): void

lines 115–124 (10)

Persist the next-run shortcut.

Parameter Type Default Description
$when ?string required Next scheduled datetime, or null to clear it

Returns: void — void

publishDuePosts()

public function publishDuePosts(): int

lines 138–155 (18)

Publish every scheduled post whose post_date has passed.

Short-circuits when the feature is disabled or when no post is due (next-run shortcut), so steady-state requests never touch the posts table. Recomputes the shortcut after each run.

Takes no parameters.

Returns: int — int Number of posts promoted to 'publish'

Imports

Alias Fully-qualified name
Sanitize ''Scriptlog\Core\Sanitize''
ConfigurationDao ''Scriptlog\Dao\ConfigurationDao''
PostDao ''Scriptlog\Dao\PostDao''

This page is generated from source by 'tools/gendoc'. Edits will be overwritten.