Documentation

EsiWidgetController extends EsiWidgetController

JsonAdapter Controller to handle EsiWidgets Usage: - Create a subclass that implements parseWidget() - Register it as a Controller in your ComponentController

Tags
copyright

CLOUDREXX CMS - Cloudrexx AG Thun

author

Project Team SS4U info@cloudrexx.com

subpackage

coremodule_news

version
1.0.0

Table of Contents

Constants

FILTER_JOIN_AND  = '&'
Flag used in filters to indicate an **AND** join.
FILTER_JOIN_OR  = '|'
Flag used in filters to indicate an **OR** join.

Properties

$cx  : Cx
Main class instance
$esiParamPage  : Page
Holds

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
getSystemComponentController()  : SystemComponentController
Returns the main controller
getWidget()  : array<string|int, mixed>
Returns the content of a widget
parseWidget()  : mixed
Parses a widget
getFileContent()  : string
Loads the content of a theme file.
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
parseFilter()  : array<string|int, mixed>
Parses a category filter expression string into a structured array.
parseWidgetNewsArticle()  : string
Renders the func_news_article widget.

Constants

FILTER_JOIN_AND

Flag used in filters to indicate an **AND** join.

protected string FILTER_JOIN_AND = '&'

When applied, articles must match all IDs listed in the filter.

FILTER_JOIN_OR

Flag used in filters to indicate an **OR** join.

protected string FILTER_JOIN_OR = '|'

When applied, articles may match any of the IDs listed in the filter.

Properties

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

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, Sigma $template, Response $response, array<string|int, mixed> $params) : mixed
Parameters
$name : string

Widget name

$template : Sigma

Widget Template

$response : Response

Response object

$params : array<string|int, mixed>

Get parameters

getFileContent()

Loads the content of a theme file.

protected getFileContent(Theme|mixed $theme, string $fileName, Response $response[, bool $parseNodePlaceholders = false ]) : string

Behavior:

  • Resolves the file path for the given theme and filename.
  • Reads the file content via File.
  • Always parses legacy BLOCK_... placeholders (via the Block component).
  • If $parseNodePlaceholders is true, also parses:
    • NODE_... placeholders (via LinkGenerator).
    • (In the future) all widgets. See CLX-1707
Parameters
$theme : Theme|mixed

The theme instance. If not a valid Theme, an empty string is returned.

$fileName : string

The file name within the theme folder (leading slashes are trimmed).

$response : Response

The response providing the current page. Falls back to the global page instance if not set.

$parseNodePlaceholders : bool = false

Whether to additionally parse NODE_... placeholders.

Return values
string

The file content (possibly parsed), or an empty string on error.

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

parseFilter()

Parses a category filter expression string into a structured array.

protected parseFilter(string $unparsedFilter) : array<string|int, mixed>

A filter string consists of numeric category IDs separated by either an AND operator (static::FILTER_JOIN_AND = &) or an OR operator (static::FILTER_JOIN_OR = |). Each ID may optionally be suffixed with "+" to indicate expansion to its subcategories.

Examples:

  • "12" → single category 12.
  • "12&34" → categories 12 and 34.
  • "12|34|56" → categories 12 or 34 or 56.
  • "12+|34" → category 12 (with subcategories) or category 34.
Parameters
$unparsedFilter : string

The raw filter string to parse.

Tags
@return

array{ ids: array<int,string>, // Category IDs as keys, "+" if expanded, "" otherwise join: string // Either {@see static::FILTER_JOIN_AND} or {@see static::FILTER_JOIN_OR} } Structured filter definition, defaulting to an empty ids list and {@see static::FILTER_JOIN_AND} join if the string is invalid.

Return values
array<string|int, mixed>

parseWidgetNewsArticle()

Renders the func_news_article widget.

protected parseWidgetNewsArticle(string $name, array<string|int, mixed> $params, Response $response, int $langId) : string

This method resolves the correct widget template file based on the widget name and template parameter, applies category filtering, fetches news headlines, and returns the rendered content.

Behavior:

Parameters
$name : string

The widget name (used to resolve the template folder).

$params : array<string|int, mixed>

Widget parameters, including:

  • theme: The theme instance to use.
  • 0: (optional) Template name (defaults to "Default").
  • 2: (optional) Category filter expression.
  • 3: (optional) Limit (integer).
  • 4: (optional) Offset (integer).
$response : Response

The response object to set expiration dates on.

$langId : int

The language ID used to fetch localized headlines.

Tags
todo

Implement widget argument

($realParams[1]). CLX-6252

Return values
string

The rendered widget content, or an empty string if no content is available.


        
On this page

Search results