RandomEsiWidgetController
extends RandomEsiWidgetController
in package
JsonAdapter Controller to handle EsiWidgets Usage: - Create a subclass that implements parseWidget() - Register it as a Controller in your ComponentController
Tags
Table of Contents
Constants
- DEFAULT_SUBWIDGET_CACHE_LIFETIME = 60 * 60 * 24
- DEFAULT_SUBWIDGET_COUNT_LIMIT = 100
Properties
- $cx : Cx
- Main class instance
- $esiParamPage : Page
- Holds
- $subwidgetCacheLifetime : int
- Max lifetime of randomized content in seconds This is only used if the number of sub-widgets is greater than $subwidgetCountLimit. In this case sub-widgets are randomly picked and cached.
- $subwidgetCountLimit : int
- Max number of sub-widgets that will be randomized per widget
Methods
- __call() : mixed
- Route methods like getName(), getType(), getDirectory(), etc.
- __construct() : mixed
- Creates new controller
- getAccessableMethods() : array<string|int, mixed>
- Returns an array of method names accessable from a JSON request
- getDefaultPermissions() : Permission
- Returns default permission as object
- getMessagesAsString() : string
- Returns all messages as string
- getName() : string
- Returns the internal name used as identifier for this adapter
- getRandomEsiWidgetContentInfos() : array<string|int, mixed>
- Returns a list of ESI request infos that are to be randomized
- getSubwidgetCacheLifetime() : int
- Returns the max lifetime of cached sub-widgets
- getSubwidgetCountLimit() : int
- Returns the max number of cached sub-widgets
- getSystemComponentController() : SystemComponentController
- Returns the main controller
- getWidget() : array<string|int, mixed>
- Returns the content of a widget
- parseWidget() : mixed
- Parses a widget
- internalParseWidget() : array<string|int, mixed>
- Parses a widget
- objectifyParams() : array<string|int, mixed>
- This makes object of the given params (if possible) Known params are page, lang, user, theme, channel, country, currency and ref
Constants
DEFAULT_SUBWIDGET_CACHE_LIFETIME
public
int
DEFAULT_SUBWIDGET_CACHE_LIFETIME
= 60 * 60 * 24
Max cache lifetime of subwidgets in seconds
DEFAULT_SUBWIDGET_COUNT_LIMIT
public
int
DEFAULT_SUBWIDGET_COUNT_LIMIT
= 100
Max count of widgets that are randomized by ESI
Properties
$cx
Main class instance
protected
Cx
$cx
= null
$esiParamPage
Holds
protected
static Page
$esiParamPage
= null
$subwidgetCacheLifetime
Max lifetime of randomized content in seconds This is only used if the number of sub-widgets is greater than $subwidgetCountLimit. In this case sub-widgets are randomly picked and cached.
protected
int
$subwidgetCacheLifetime
Cache lifetime in seconds
$subwidgetCountLimit
Max number of sub-widgets that will be randomized per widget
protected
int
$subwidgetCountLimit
Sub-widget count
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
Attributes
- #[ReturnTypeWillChange]
Return values
mixed —Return value of the method to call
__construct()
Creates new controller
public
__construct(SystemComponentController $systemComponentController, Cx $cx) : mixed
Parameters
- $systemComponentController : SystemComponentController
-
Main controller for this system component
- $cx : Cx
-
Main class instance
Tags
getAccessableMethods()
Returns an array of method names accessable from a JSON request
public
getAccessableMethods() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —List of method names
getDefaultPermissions()
Returns default permission as object
public
getDefaultPermissions() : Permission
Tags
Return values
Permission —Required permission
getMessagesAsString()
Returns all messages as string
public
getMessagesAsString() : string
Tags
Return values
string —HTML encoded error messages
getName()
Returns the internal name used as identifier for this adapter
public
getName() : string
Tags
Return values
string —Name of this adapter
getRandomEsiWidgetContentInfos()
Returns a list of ESI request infos that are to be randomized
public
getRandomEsiWidgetContentInfos(Widget $widget, array<string|int, mixed> $params, mixed $template) : array<string|int, mixed>
Each returned entry consists of an array like:
array(
<adapterName>,
<adapterMethod>,
Parameters
- $widget : Widget
-
The RandomEsiWidget
- $params : array<string|int, mixed>
-
ESI request params
- $template : mixed
Return values
array<string|int, mixed> —List of URLs
getSubwidgetCacheLifetime()
Returns the max lifetime of cached sub-widgets
public
getSubwidgetCacheLifetime() : int
Return values
int —Lifetime in seconds
getSubwidgetCountLimit()
Returns the max number of cached sub-widgets
public
getSubwidgetCountLimit() : int
Return values
int —Number of widgets
getSystemComponentController()
Returns the main controller
public
getSystemComponentController() : SystemComponentController
Return values
SystemComponentController —Main controller for this system component
getWidget()
Returns the content of a widget
public
getWidget(array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
- $params : array<string|int, mixed>
-
JsonAdapter parameters
Return values
array<string|int, mixed> —Content in an associative array
parseWidget()
Parses a widget
public
parseWidget(string $name, mixed $template, Response $response, array<string|int, mixed> $params) : mixed
Parameters
- $name : string
-
Widget name
- $template : mixed
- $response : Response
-
Current response
- $params : array<string|int, mixed>
-
Array of params
Tags
internalParseWidget()
Parses a widget
protected
internalParseWidget(Widget $widget, array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
- $widget : Widget
-
The Widget
- $params : array<string|int, mixed>
-
Params passed by ESI (/API) request
Return values
array<string|int, mixed> —Content in an associative array
objectifyParams()
This makes object of the given params (if possible) Known params are page, lang, user, theme, channel, country, currency and ref
protected
objectifyParams(array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
- $params : array<string|int, mixed>
-
Associative array of params
Return values
array<string|int, mixed> —Associative array of params