Documentation

AbstractTemplate
in package

AbstractYes

Abstract implementation of a single template with common attributes.

Due to its nature of API responses and flexibility, the properties are loose (public) and does not have a validation.

Table of Contents

Constants

STATUS_DRAFT  = 'draft'
STATUS_PUBLISHED  = 'published'
TIER_FREE  = 'free'
TIER_PRO  = 'pro'

Properties

$consumerData  : array<string|int, mixed>
Calculated consumer data which can be filled by middlewares.
$createdAt  : int
Meta data: creation date and time of template version (service cloud saves templates immutable so each new version gets an own updated `createdAt` -> no `modifiedAt` needed).
$enabledWhenOneOf  : array<string|int, string>
Meta data: rules overwriting the `isDisabled` property.
$extendsIdentifier  : string
Meta data: when this template got extended this is the parent identifier.
$headline  : string
Meta data: headline.
$id  : int
Meta data: external ID within service cloud.
$identifier  : string
Meta data: Unique identifier within service cloud.
$isHidden  : int
Meta data: only store the template but never show e.g. in frontend.
$language  : string
Meta data: Language in 2-char.
$logoUrl  : mixed
Meta data: logo of template.
$name  : string
Meta data: name
$recommendedWhenOneOf  : array<string|int, string>
Meta data: rules overwriting the `consumerData['isRecommended']` property.
$status  : string
Meta data: status within the service cloud (`published`, `draft`).
$subHeadline  : string
Meta data: sub headline.
$successorOfIdentifierInfo  : array<string|int, array<string|int, mixed>>
A list of identifiers that replaces this template, as the old template has been deleted.
$tier  : string
Meta data: Can be `free` or `pro`.
$version  : int
Meta data: headline.
$beforeMiddleware  : array<string|int, mixed>
Original, before running any middleware, template data. This is useful for external data sources which should really be contaced e.g. once a day and a invalidation should only "retrigger" recalculation of middlewares.
$consumer  : mixed

Methods

__clone()  : mixed
__construct()  : mixed
C'tor.
fromArray()  : mixed
Override all properties from an array.
getBeforeMiddleware()  : mixed
Getter.
getConsumer()  : mixed
Getter.
memoizeBeforeMiddleware()  : mixed
Memoize current state of template so it can be retrieved with `getBeforeMiddleware` after running all middlewares.
retrieved()  : mixed
Run all `beforeRetrievingTemplate` middlewares.
toArray()  : mixed
Output this service template as array. This is statically available to make usage with `array_map` more easier.
toArrays()  : mixed
Output multiple service templates as array representation.
use()  : static
Modifies the template data through middleware and e.g. replaces content, variables, .

Constants

Properties

$consumerData

Calculated consumer data which can be filled by middlewares.

public array<string|int, mixed> $consumerData = ['tags' => []]

Predefined data:

tags                     = string[]
-- List of tags (like badges), key = Badge text, value = Tooltip text

isCreated                = boolean
-- Is the template created in the consumer environment?

id                       = int
-- ID of the record within the consumer environment using this template

rules                    = string[]
-- Flattened string array of all rule-expressions

isDisabled               = boolean
-- Is this template enabled within this consumer environment (e.g. WordPress plugin active?).

isRecommended            = boolean
-- Is this template recommended within this consumer environment (e.g. Cloudflare detected).

scan                     = { foundCount: number; foundOnSitesCount: number; lastScanned?: string; }
-- Scan results for a given template by identifier.

isIgnored                = boolean
-- Is this template ignored within this consumer environment (e.g. ignored in scanner results).

successorOf              = Array<{ identifier: string; id: int; }>
-- If a template is a successor to another template, this array holds infos about the ID of the record within the consumer environment using this template

$createdAt

Meta data: creation date and time of template version (service cloud saves templates immutable so each new version gets an own updated `createdAt` -> no `modifiedAt` needed).

public int $createdAt

$enabledWhenOneOf

Meta data: rules overwriting the `isDisabled` property.

public array<string|int, string> $enabledWhenOneOf = []

$extendsIdentifier

Meta data: when this template got extended this is the parent identifier.

public string $extendsIdentifier

$identifier

Meta data: Unique identifier within service cloud.

public string $identifier

$isHidden

Meta data: only store the template but never show e.g. in frontend.

public int $isHidden

$recommendedWhenOneOf

Meta data: rules overwriting the `consumerData['isRecommended']` property.

public array<string|int, string> $recommendedWhenOneOf = []

$status

Meta data: status within the service cloud (`published`, `draft`).

public string $status

$successorOfIdentifierInfo

A list of identifiers that replaces this template, as the old template has been deleted.

public array<string|int, array<string|int, mixed>> $successorOfIdentifierInfo = []

$beforeMiddleware

Original, before running any middleware, template data. This is useful for external data sources which should really be contaced e.g. once a day and a invalidation should only "retrigger" recalculation of middlewares.

private array<string|int, mixed> $beforeMiddleware = null

This data can be for example be saved in a Redis object cache or database column.

Methods

fromArray()

Override all properties from an array.

public fromArray(array<string|int, mixed> $arr) : mixed
Parameters
$arr : array<string|int, mixed>

getBeforeMiddleware()

Getter.

public getBeforeMiddleware() : mixed
Tags
codeCoverageIgnore

getConsumer()

Getter.

public getConsumer() : mixed
Tags
codeCoverageIgnore

memoizeBeforeMiddleware()

Memoize current state of template so it can be retrieved with `getBeforeMiddleware` after running all middlewares.

public memoizeBeforeMiddleware() : mixed

retrieved()

Run all `beforeRetrievingTemplate` middlewares.

public retrieved() : mixed

use()

Modifies the template data through middleware and e.g. replaces content, variables, .

public use() : static

..

Return values
static

        
On this page

Search results