This is an old revision of the document!
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 (0)
None declared.
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'' | [[scriptlog:lib:dao:postdao|''PostDao'']] | //required// | //none// | | ''$configDao'' | [[scriptlog:lib:dao:configurationdao|''ConfigurationDao'']] | //required// | //none// | | ''$sanitize'' | [[scriptlog:lib:core: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:lib:core:sanitize|''Scriptlog\Core\Sanitize'']] | | ''ConfigurationDao'' | [[scriptlog:lib:dao:configurationdao|''Scriptlog\Dao\ConfigurationDao'']] | | ''PostDao'' | [[scriptlog:lib:dao:postdao|''Scriptlog\Dao\PostDao'']] |
This page is generated from source by 'tools/gendoc'. Edits will be overwritten.
