tp TouchPointWP Stats - TenthPres/TouchPoint-WP GitHub Wiki
tp\TouchPointWP\Stats
Keep track of some basic stats that are helpful for Tenth to support other churches using the plugin.
- Full name:
\tp\TouchPointWP\Stats - This class implements:
\tp\TouchPointWP\Interfaces\api,JsonSerializable,\tp\TouchPointWP\Interfaces\updatesViaCron
Constants
| Constant | Visibility | Type | Value |
|---|---|---|---|
CRON_HOOK |
public | \tp\TouchPointWP\TouchPointWP::HOOK_PREFIX . 'stats_submit' | |
SUBMISSION_ENDPOINT |
public | 'https://www.tenth.org/touchpoint-api/stats/submit' |
Methods
__destruct
Make sure saves have happened before the object is destroyed.
public __destruct(): mixed
Throws:
Exception
load
Loads the module and initializes the other actions.
public static load(): bool
- This method is static.
migrate
Call home, triggered by migration.
public static migrate(): void
- This method is static.
updateCron
Call home, triggered by cron.
public static updateCron(): void
- This method is static.
checkUpdates
Check to see if a cron run is needed, and run it if so. Connected to an init function.
public static checkUpdates(): void
- This method is static.
updateDb
Save the stats to the database.
public updateDb(): bool
Return Value:
true on success (or if an update wasn't needed), false on failure.
__set
Setter. Allows particular statistics to be set.
public __set(mixed $name, mixed $value): void
Parameters:
| Parameter | Type | Description |
|---|---|---|
$name |
mixed | |
$value |
mixed |
Throws:
InvalidArgumentException
__get
public __get(string $name): void
Parameters:
| Parameter | Type | Description |
|---|---|---|
$name |
string |
Throws:
InvalidArgumentException
getStatsForSubmission
Assemble the information that's submitted.
public getStatsForSubmission(bool $updateQueried = false): array
Parameters:
| Parameter | Type | Description |
|---|---|---|
$updateQueried |
bool |
jsonSerialize
Assemble the object into a format that can be serialized to JSON. Only includes the parameters that are part of this class, not those that are loaded from the database separately, such as version numbers.
public jsonSerialize(): array
instance
Get the singleton.
public static instance(): \tp\TouchPointWP\Stats
- This method is static.
api
Handle API requests
public static api(array $uri): bool
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$uri |
array | The request URI already parsed by parse_url() |
Return Value:
False if endpoint is not found. Should print the result.
handleSubmission
Handle submissions received to this site (presumably tenth.org) from other users of the plugin.
public static handleSubmission(): bool
- This method is static. Return Value:
True on success