Report
in package
implements
api, module, JsonSerializable, updatesViaCron
The Report class gets and processes a SQL or Python report from TouchPoint and presents it in the UX.
Table of Contents
Interfaces
- api
- API Interface
- module
- This is a base interface for all feature classes.
- JsonSerializable
- updatesViaCron
- Interface to standardize items that are updated with Cron.
Constants
- CRON_HOOK = \tp\TouchPointWP\TouchPointWP::HOOK_PREFIX . "report_cron_hook"
- DEFAULT_CONTENT = ''
- META_PREFIX = \tp\TouchPointWP\TouchPointWP::SETTINGS_PREFIX . "rpt_"
- NAME_META_KEY = self::META_PREFIX . "name"
- P1_META_KEY = self::META_PREFIX . "p1"
- POST_TYPE = \tp\TouchPointWP\TouchPointWP::HOOK_PREFIX . "report"
- SHORTCODE_REPORT = \tp\TouchPointWP\TouchPointWP::SHORTCODE_PREFIX . "Report"
- TYPE_META_KEY = self::META_PREFIX . "type"
Properties
- $_isLoaded : bool
Methods
- api() : bool
- Handle API requests
- checkUpdates() : void
- Check to see if a cron run is needed, and run it if so. Connected to an init function.
- content() : string
- Get the report content. If no content is available, return the provided default content instead.
- fromParams() : self
- Get a Report object, based on standard parameters (generally, the parameters used for the shortcode)
- getPost() : WP_Post|null
- Get the WP_Post object corresponding to the Report.
- init() : void
- Register stuff
- intervalAsDateInterval() : DateInterval
- Get the update Interval as a DateInterval for use with DateTime functions.
- jsonSerialize() : object
- Handle which data should be converted to JSON. Used for posting to the API.
- load() : bool
- Loads the module and initializes the other actions.
- needsUpdate() : bool
- Determines if THIS report is due for an update. Does NOT process the update itself.
- reportShortcode() : string
- Handle the report shortcode.
- updateCron() : void
- Run the updating cron task. Fail quietly to not disturb the visitor experience if using WP default cron handling.
- updateFromTouchPoint() : int
- Update all reports from TouchPoint that are due for an update.
Constants
CRON_HOOK
public
mixed
CRON_HOOK
= \tp\TouchPointWP\TouchPointWP::HOOK_PREFIX . "report_cron_hook"
DEFAULT_CONTENT
public
mixed
DEFAULT_CONTENT
= ''
META_PREFIX
public
mixed
META_PREFIX
= \tp\TouchPointWP\TouchPointWP::SETTINGS_PREFIX . "rpt_"
NAME_META_KEY
public
mixed
NAME_META_KEY
= self::META_PREFIX . "name"
P1_META_KEY
public
mixed
P1_META_KEY
= self::META_PREFIX . "p1"
POST_TYPE
public
mixed
POST_TYPE
= \tp\TouchPointWP\TouchPointWP::HOOK_PREFIX . "report"
SHORTCODE_REPORT
public
mixed
SHORTCODE_REPORT
= \tp\TouchPointWP\TouchPointWP::SHORTCODE_PREFIX . "Report"
TYPE_META_KEY
public
mixed
TYPE_META_KEY
= self::META_PREFIX . "type"
Properties
$_isLoaded
public
static bool
$_isLoaded
= false
Methods
api()
Handle API requests
public
static api(array<string|int, mixed> $uri) : bool
Parameters
- $uri : array<string|int, mixed>
-
The request URI already parsed by parse_url()
Return values
bool —False if endpoint is not found. Should print the result.
checkUpdates()
Check to see if a cron run is needed, and run it if so. Connected to an init function.
public
static checkUpdates() : void
content()
Get the report content. If no content is available, return the provided default content instead.
public
content([string $contentIfError = self::DEFAULT_CONTENT ]) : string
Parameters
- $contentIfError : string = self::DEFAULT_CONTENT
Return values
stringfromParams()
Get a Report object, based on standard parameters (generally, the parameters used for the shortcode)
public
static fromParams(mixed $params) : self
Parameters
- $params : mixed
Tags
Return values
selfgetPost()
Get the WP_Post object corresponding to the Report.
public
getPost([bool $create = false ]) : WP_Post|null
Parameters
- $create : bool = false
-
Set true if the post should be created if it doesn't exist.
Return values
WP_Post|nullinit()
Register stuff
public
static init() : void
intervalAsDateInterval()
Get the update Interval as a DateInterval for use with DateTime functions.
public
intervalAsDateInterval() : DateInterval
Return values
DateIntervaljsonSerialize()
Handle which data should be converted to JSON. Used for posting to the API.
public
jsonSerialize() : object
Return values
object —data which can be serialized by json_encode
load()
Loads the module and initializes the other actions.
public
static load() : bool
Return values
boolneedsUpdate()
Determines if THIS report is due for an update. Does NOT process the update itself.
public
needsUpdate() : bool
Return values
boolreportShortcode()
Handle the report shortcode.
public
static reportShortcode([mixed $params = [] ][, string $content = "" ]) : string
Parameters
- $params : mixed = []
- $content : string = ""
Return values
stringupdateCron()
Run the updating cron task. Fail quietly to not disturb the visitor experience if using WP default cron handling.
public
static updateCron() : void
updateFromTouchPoint()
Update all reports from TouchPoint that are due for an update.
public
static updateFromTouchPoint([bool $forceEvenIfNotDue = false ]) : int
Parameters
- $forceEvenIfNotDue : bool = false