Documentation

RandomEsiWidget extends EsiWidget

Represents a template widget that contains randomized content

This class' only use is to identify such widgets. Randomizing is done in EsiWidgetController

Tags
copyright

CLOUDREXX CMS - Cloudrexx AG Thun

author

Michael Ritter michael.ritter@cloudrexx.com

subpackage

coremodules_widget

version
1.0.0

Table of Contents

Constants

ESI_VAR_ID_AUTOCONF  : mixed = -1
This will just make a most-of-the-time-working setup and should not be used on production without checking first.
ESI_VAR_ID_CHANNEL  : mixed = 8
ESI_VAR_ID_COUNTRY  : mixed = 64
ESI_VAR_ID_CURRENCY  : mixed = 32
ESI_VAR_ID_LOCALE  : mixed = 2
ESI_VAR_ID_PAGE  : mixed = 1
ESI_VAR_ID_PATH  : mixed = 128
ESI_VAR_ID_QUERY  : mixed = 256
ESI_VAR_ID_THEME  : mixed = 4
ESI_VAR_ID_USER  : mixed = 16
ESI_VAR_NAME_CHANNEL  : mixed = 'channel'
ESI_VAR_NAME_COUNTRY  : mixed = 'country'
ESI_VAR_NAME_CURRENCY  : mixed = 'currency'
ESI_VAR_NAME_LOCALE  : mixed = 'locale'
ESI_VAR_NAME_PAGE  : mixed = 'page'
ESI_VAR_NAME_PATH  : mixed = 'path'
ESI_VAR_NAME_QUERY  : mixed = 'query'
ESI_VAR_NAME_THEME  : mixed = 'theme'
ESI_VAR_NAME_USER  : mixed = 'user'
TYPE_BLOCK  : string = 'block'
TYPE_CALLBACK  : string = 'callback'
TYPE_PLACEHOLDER  : string = 'placeholder'

Properties

$component  : SystemComponentController
Component which registered this widget
$customParseTarget  : WidgetParseTarget
Custom parse target to use for sub-widgets
$esiVariables  : int
ESI variables configured to be sent for this Widget
$jsonAdapterName  : mixed
$jsonMethodName  : mixed
$jsonParams  : mixed
$localeCodes  : array<string|int, mixed>
List of locale codes ordered by translation fallback order per Cx instance
$name  : string
Name of this widget
$nestingCount  : int
Counts the nesting level of __call()
$stringRepresentationBlank  : bool
Whether blank string representations are valid
$stringRepresentationFields  : array<string|int, mixed>
List of fields that should be available in the string representation
$stringRepresentationFormat  : string
Sprintf format for the string representation
$triggerEvents  : bool
$type  : string
Whether this widget represents a template block, placeholder or callback
$uniqueRepetitionCount  : int
$validators  : array<string|int, mixed>
Initialize this array as follows: array( 'columName' => Zend_Validate )
$virtual  : bool
Defines if an entity is virtual and therefore not persistable.

Methods

__call()  : mixed
Route methods like getName(), getType(), getDirectory(), etc.
__construct()  : mixed
Instanciates a new widget
__get()  : mixed
This is an ugly solution to allow $this->cx to be available in all entity classes Since the entity's constructor is not called when an entity is loaded from DB this cannot be assigned there.
__toString()  : string
Returns this entity's identifying value
clearCache()  : mixed
Clears all cache files for this Widget (if any)
getComponentController()  : SystemComponent
Returns the component controller for this component
getCustomParseTarget()  : WidgetParseTarget
Returns this widget's custom parse target
getEsiVariables()  : int
Returns the ESI variables configured to be send for this Widget Return value is a combination of othered constants
getJsonAdapterName()  : string
Returns the name of the JsonAdapter to call
getJsonMethodName()  : string
Returns the name of the JsonAdapter method to call
getKeyAsString()  : string
Returns this entity's key
getName()  : string
Returns the name of this widget
getRegisteringComponent()  : SystemComponentController
Returns the component which registered this widget
getTranslatedFieldValue()  : mixed
Returns the value of a translatable field using fallback mechanisms
getType()  : string
Returns whether this widget represents a template placeholder, block or callback
getUniqueRepetitionCount()  : int
Returns the number of unique repetitions of this widget
hasCustomParseTarget()  : bool
Tells whether this widget has a custom parse target
initializeValidators()  : mixed
Set $this->validators
internalParse()  : string
Really parses this widget into $template If this Widget has no content, the replacement can simply be returned as string. Otherwise the replacement must be done in $template.
isEsiVariableActive()  : mixed
Tells wheter the given ESI variable is configured to be sent for this Widget
isVirtual()  : bool
Returns the virtuality of the entity
parse()  : mixed
Parses this widget into $template Depending on the type, the passed params and return value are different: TYPE_CALLBACK: $params are the callback's params $excludeWidgets is always empty return value is the content of this widget TYPE_PLACEHOLDER: $params are always empty $excludedWidgets is the list of Widgets we already recursed through return value is the content of this widget TYPE_BLOCK $params are always empty $excludedWidgets is the list of Widgets we already recursed through return value is empty string (/unused)
setCustomParseTarget()  : mixed
Sets this widget's parse target
setEsiVariable()  : mixed
Sets the ESI variable as active
setEsiVariables()  : mixed
Sets the ESI variables configured to be sent for this widget Simple setter, see getEsiVariables() for format definition
setUniqueRepetitionCount()  : mixed
Sets the number of unique repetitions of this widget
setVirtual()  : mixed
Set the virtuality of the entity
unsetEsiVariable()  : mixed
Sets the ESI variable as inactive
validate()  : mixed
getEsiParams()  : array<string|int, mixed>
Returns the params for the JsonAdapter call If you add an ESI variable core_module Cache needs to be updated as well: - Controller\CacheLib (multiple times) - Model\Entity\ReverseProxyCloudrexx::globDrop()
getFallbackLocaleCodes()  : array<string|int, mixed>
Returns a list of all locale codes ordered by fallback order
getStringRepresentationBlank()  : bool
Whether blank string representations are valid
getStringRepresentationFields()  : array<string|int, mixed>
Returns a list of fields available in the string representation
getStringRepresentationFormat()  : string
Returns the sprintf() format for the string representation

Constants

ESI_VAR_ID_AUTOCONF

This will just make a most-of-the-time-working setup and should not be used on production without checking first.

public mixed ESI_VAR_ID_AUTOCONF = -1
Tags
const

int Index for ESI auto-configuration

ESI_VAR_ID_CHANNEL

public mixed ESI_VAR_ID_CHANNEL = 8
Tags
const

int Index for ESI variable for channel

ESI_VAR_ID_COUNTRY

public mixed ESI_VAR_ID_COUNTRY = 64
Tags
const

int Index for ESI variable for country

ESI_VAR_ID_CURRENCY

public mixed ESI_VAR_ID_CURRENCY = 32
Tags
const

int Index for ESI variable for currency

ESI_VAR_ID_LOCALE

public mixed ESI_VAR_ID_LOCALE = 2
Tags
const

int Index for ESI variable for locale

ESI_VAR_ID_PAGE

public mixed ESI_VAR_ID_PAGE = 1
Tags
const

int Index for ESI variable for page

ESI_VAR_ID_PATH

public mixed ESI_VAR_ID_PATH = 128
Tags
const

int Index for ESI variable for additional path parts

ESI_VAR_ID_QUERY

public mixed ESI_VAR_ID_QUERY = 256
Tags
const

int Index for ESI variable for query string

ESI_VAR_ID_THEME

public mixed ESI_VAR_ID_THEME = 4
Tags
const

int Index for ESI variable for theme

ESI_VAR_ID_USER

public mixed ESI_VAR_ID_USER = 16
Tags
const

int Index for ESI variable for user

ESI_VAR_NAME_CHANNEL

public mixed ESI_VAR_NAME_CHANNEL = 'channel'
Tags
const

string Name of ESI variable for channel

ESI_VAR_NAME_COUNTRY

public mixed ESI_VAR_NAME_COUNTRY = 'country'
Tags
const

string Name of ESI variable for country

ESI_VAR_NAME_CURRENCY

public mixed ESI_VAR_NAME_CURRENCY = 'currency'
Tags
const

string Name of ESI variable for currency

ESI_VAR_NAME_LOCALE

public mixed ESI_VAR_NAME_LOCALE = 'locale'
Tags
const

string Name of ESI variable for locale

ESI_VAR_NAME_PAGE

public mixed ESI_VAR_NAME_PAGE = 'page'
Tags
const

string Name of ESI variable for page

ESI_VAR_NAME_PATH

public mixed ESI_VAR_NAME_PATH = 'path'
Tags
const

string Name of ESI variable for additional path parts

ESI_VAR_NAME_QUERY

public mixed ESI_VAR_NAME_QUERY = 'query'
Tags
const

string Name of ESI variable for query string

ESI_VAR_NAME_THEME

public mixed ESI_VAR_NAME_THEME = 'theme'
Tags
const

string Name of ESI variable for theme

ESI_VAR_NAME_USER

public mixed ESI_VAR_NAME_USER = 'user'
Tags
const

string Name of ESI variable for user

TYPE_BLOCK

public string TYPE_BLOCK = 'block'

Widget is a block that can be parsed

TYPE_CALLBACK

public string TYPE_CALLBACK = 'callback'

Widget is a placeholder that has params and triggers a callback

TYPE_PLACEHOLDER

public string TYPE_PLACEHOLDER = 'placeholder'

Widget is a simple placeholder

Properties

$esiVariables

ESI variables configured to be sent for this Widget

protected int $esiVariables = self::ESI_VAR_ID_AUTOCONF

Combination of the constants

$localeCodes

List of locale codes ordered by translation fallback order per Cx instance

protected static array<string|int, mixed> $localeCodes = array()

Array in the form: array(<instanceId> => array(<localeCode>, ...))

Tags
see
getFallbackLocaleCodes()

$nestingCount

Counts the nesting level of __call()

protected static int $nestingCount = 0

$stringRepresentationBlank

Whether blank string representations are valid

protected bool $stringRepresentationBlank = false

Whether blank string representations are valid

Tags
see
getStringRepresentationBlank()

$stringRepresentationFields

List of fields that should be available in the string representation

protected array<string|int, mixed> $stringRepresentationFields = array()

List of field names

Tags
see
getStringRepresentationFields()

$stringRepresentationFormat

Sprintf format for the string representation

protected string $stringRepresentationFormat = ''

Sprintf format string

Tags
see
getStringRepresentationFormat()

$triggerEvents

protected bool $triggerEvents = true

Whether to trigger events

$type

Whether this widget represents a template block, placeholder or callback

protected string $type

$uniqueRepetitionCount

protected int $uniqueRepetitionCount = 1

Number of unique repetitions

$validators

Initialize this array as follows: array( 'columName' => Zend_Validate )

protected array<string|int, mixed> $validators = array()

$virtual

Defines if an entity is virtual and therefore not persistable.

protected bool $virtual = false

Defaults to FALSE - not virtual.

Methods

__call()

Route methods like getName(), getType(), getDirectory(), etc.

public __call(string $methodName, array<string|int, mixed> $arguments) : mixed
Parameters
$methodName : string

Name of method to call

$arguments : array<string|int, mixed>

List of arguments for the method to call

Tags
throws
Exception

If __call() nesting level reaches 20

Attributes
#[ReturnTypeWillChange]
Return values
mixed —

Return value of the method to call

__construct()

Instanciates a new widget

public __construct(SystemComponentController $component, string $name[, string $type = self::TYPE_PLACEHOLDER ][, string $jsonAdapterName = '' ][, string $jsonMethodName = '' ][, array<string|int, mixed> $jsonParams = array() ]) : mixed
Parameters
$component : SystemComponentController

Component registering this widget

$name : string

Name of this widget

$type : string = self::TYPE_PLACEHOLDER

(optional) Whether this widget represents a template placeholder, block or callback, default: placeholder

$jsonAdapterName : string = ''

(optional) Name of the JsonAdapter to call. If not specified, $component->getName() is used

$jsonMethodName : string = ''

(optional) Name of the JsonAdapter method to call. If not specified, "getWidget" is used

$jsonParams : array<string|int, mixed> = array()

(optional) Params to pass on JsonAdapter call. If not specified, a default list is used, see getEsiParams()

__get()

This is an ugly solution to allow $this->cx to be available in all entity classes Since the entity's constructor is not called when an entity is loaded from DB this cannot be assigned there.

public __get(mixed $name) : mixed
Parameters
$name : mixed
Attributes
#[ReturnTypeWillChange]

__toString()

Returns this entity's identifying value

public __toString() : string

By default this returns the same as getKeyAsString(), but this method might get overridden by subclasses.

Return values
string —

Identifying value for this entity

clearCache()

Clears all cache files for this Widget (if any)

public clearCache() : mixed

getEsiVariables()

Returns the ESI variables configured to be send for this Widget Return value is a combination of othered constants

public getEsiVariables() : int
Return values
int —

Bitwise-OR-combined values

getJsonAdapterName()

Returns the name of the JsonAdapter to call

public getJsonAdapterName() : string
Return values
string —

JsonAdapter name

getJsonMethodName()

Returns the name of the JsonAdapter method to call

public getJsonMethodName() : string
Return values
string —

JsonAdapter method name

getKeyAsString()

Returns this entity's key

public final getKeyAsString([string $separator = '/' ]) : string

If this entity has a composite key, the fields are separated by $separator.

Parameters
$separator : string = '/'

(optional) Separator for composite key fields, default "/"

Return values
string —

Entity key as string

getName()

Returns the name of this widget

public getName() : string
Return values
string —

Name of this widget

getTranslatedFieldValue()

Returns the value of a translatable field using fallback mechanisms

public getTranslatedFieldValue(string $fieldName) : mixed

If the field is not translatable its value is returned anyway. Tries to return the value in the following locales (if non-empty):

  • Current locale
  • Default locale
  • All other locales
Parameters
$fieldName : string

Name of a translatable field

getType()

Returns whether this widget represents a template placeholder, block or callback

public getType() : string
Return values
string —

$type Whether this widget represents a template placeholder, block or callback

getUniqueRepetitionCount()

Returns the number of unique repetitions of this widget

public getUniqueRepetitionCount() : int
Return values
int —

Number of unique repetitions

hasCustomParseTarget()

Tells whether this widget has a custom parse target

public hasCustomParseTarget() : bool
Return values
bool —

True if this widget has a custom parse target

initializeValidators()

Set $this->validators

public initializeValidators() : mixed

Validators can be found in lib/FRAMEWORK/Validator.class.php These will be executed if validate() is called

internalParse()

Really parses this widget into $template If this Widget has no content, the replacement can simply be returned as string. Otherwise the replacement must be done in $template.

public internalParse(mixed $template, mixed $response, mixed $targetComponent, mixed $targetEntity, mixed $targetId[, mixed $params = array() ]) : string
Parameters
$template : mixed

Template to parse this widget into

$response : mixed

Current response object

$targetComponent : mixed

Parse target component name

$targetEntity : mixed

Parse target entity name

$targetId : mixed

Parse target entity ID

$params : mixed = array()

(optional) List of params for widgets of type 'callback'

Return values
string —

Replacement for widgets without content, NULL otherwise

isEsiVariableActive()

Tells wheter the given ESI variable is configured to be sent for this Widget

public isEsiVariableActive(mixed $variableId) : mixed
Parameters
$variableId : mixed

isVirtual()

Returns the virtuality of the entity

public isVirtual() : bool
Return values
bool —

TRUE if the entity is virtual, otherwise FALSE

parse()

Parses this widget into $template Depending on the type, the passed params and return value are different: TYPE_CALLBACK: $params are the callback's params $excludeWidgets is always empty return value is the content of this widget TYPE_PLACEHOLDER: $params are always empty $excludedWidgets is the list of Widgets we already recursed through return value is the content of this widget TYPE_BLOCK $params are always empty $excludedWidgets is the list of Widgets we already recursed through return value is empty string (/unused)

public parse(HTML_Template_Sigma $template, Reponse $response, string $targetComponent, string $targetEntity, string $targetId[, mixed $arguments = array() ][, array<string|int, mixed> $excludedWidgets = array() ]) : mixed
Parameters
$template : HTML_Template_Sigma

Template to parse this widget into

$response : Reponse

Current response object

$targetComponent : string

Parse target component name

$targetEntity : string

Parse target entity name

$targetId : string

Parse target entity ID

$arguments : mixed = array()
$excludedWidgets : array<string|int, mixed> = array()

(optional) List of widget names that shall not be parsed

setEsiVariable()

Sets the ESI variable as active

public setEsiVariable(mixed $variableId) : mixed
Parameters
$variableId : mixed

setEsiVariables()

Sets the ESI variables configured to be sent for this widget Simple setter, see getEsiVariables() for format definition

public setEsiVariables(int $variables) : mixed
Parameters
$variables : int

Bitwise-OR-combined values

setUniqueRepetitionCount()

Sets the number of unique repetitions of this widget

public setUniqueRepetitionCount(int $count) : mixed
Parameters
$count : int

Number of unique repetitions

setVirtual()

Set the virtuality of the entity

public setVirtual(bool $virtual) : mixed
Parameters
$virtual : bool

TRUE to set the entity as virtual or otherwise to FALSE

unsetEsiVariable()

Sets the ESI variable as inactive

public unsetEsiVariable(mixed $variableId) : mixed
Parameters
$variableId : mixed

getEsiParams()

Returns the params for the JsonAdapter call If you add an ESI variable core_module Cache needs to be updated as well: - Controller\CacheLib (multiple times) - Model\Entity\ReverseProxyCloudrexx::globDrop()

protected getEsiParams(string $targetComponent, string $targetEntity, string $targetId) : array<string|int, mixed>
Parameters
$targetComponent : string

Parse target component name

$targetEntity : string

Parse target entity name

$targetId : string

Parse target entity ID

Return values
array<string|int, mixed> —

List of params

getFallbackLocaleCodes()

Returns a list of all locale codes ordered by fallback order

protected getFallbackLocaleCodes() : array<string|int, mixed>
  • First entry is the current locale
  • Second entry is the default locale (if different from current, it's omitted otherwise)
  • Then all other locales follow (in no particular order)
Tags
todo

Order the array by the fallback order (same as in ContentManager)

Return values
array<string|int, mixed> —

List of locale codes

getStringRepresentationBlank()

Whether blank string representations are valid

protected getStringRepresentationBlank() : bool
Return values
bool —

Whether blank string representations are valid

getStringRepresentationFields()

Returns a list of fields available in the string representation

protected getStringRepresentationFields() : array<string|int, mixed>
Return values
array<string|int, mixed> —

List of field names

getStringRepresentationFormat()

Returns the sprintf() format for the string representation

protected getStringRepresentationFormat() : string
Return values
string —

sprintf() format string

On this page

Search results