FrontendController
extends SystemComponentFrontendController
in package
Specific FrontendController for this Component. Use this to easily create a frontent view
Tags
Table of Contents
Properties
- $currentEntityStack : array<string|int, mixed>
- $cx : Cx
- Main class instance
- $widgetAvailabilityMap : array<string|int, mixed>
Methods
- __call() : mixed
- Route methods like getName(), getType(), getDirectory(), etc.
- __construct() : mixed
- Creates new controller
- getPage() : mixed
- This is called by the default ComponentController and does all the repeating work
- getSystemComponentController() : SystemComponentController
- Returns the main controller
- parsePage() : mixed
- Use this to parse your frontend page
- getAvailableWidgets() : array<string|int, mixed>
- Returns the list of available widgets within a widget or cmd
- getViewConfig() : array<string|int, mixed>
- Returns the view config for a given view name
- parseEntitiesToTemplate() : void
- Parses a list of entities to a template based on a view config
- parseEntityToTemplate() : void
- Parses an entity to a template based on a view config
- parseWidget() : string|null
- Parse a widget
- parseWidgets() : void
- Parses all available widget within the given CMD
- resolveCmd() : string
- Returns the integration CMD by the requested page CMD
- setTypedWidget() : void
- Sets the widget's value in the template
- setWidget() : void
- Sets the widget's value in the template
Properties
$currentEntityStack
protected
array<string|int, mixed>
$currentEntityStack
= array()
Stack of entities. Topmost is the currently parsed entity
$cx
Main class instance
protected
Cx
$cx
= null
$widgetAvailabilityMap
protected
array<string|int, mixed>
$widgetAvailabilityMap
= array('cmd' => array(), 'widget' => array())
Cached map for widget availability
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
getPage()
This is called by the default ComponentController and does all the repeating work
public
getPage(Page $page) : mixed
This creates a template of the page content and calls parsePage($template)
Parameters
- $page : Page
-
Resolved page
getSystemComponentController()
Returns the main controller
public
getSystemComponentController() : SystemComponentController
Return values
SystemComponentController —Main controller for this system component
parsePage()
Use this to parse your frontend page
public
parsePage(Sigma $template) : mixed
You will get a template based on the content of the resolved page You can access Cx class using $this->cx To show messages, use \Message class
Parameters
- $template : Sigma
-
Template containing content of resolved page
getAvailableWidgets()
Returns the list of available widgets within a widget or cmd
protected
getAvailableWidgets(string $parent, bool $isWidget) : array<string|int, mixed>
Parameters
- $parent : string
-
Parent identifier to parse
- $isWidget : bool
-
Whether
$parentis a widget or a cmd.
Return values
array<string|int, mixed> —List of widget identifiers
getViewConfig()
Returns the view config for a given view name
protected
getViewConfig(string $viewName) : array<string|int, mixed>
Parameters
- $viewName : string
-
Name of the view config to fetch
Tags
Return values
array<string|int, mixed> —View properties
parseEntitiesToTemplate()
Parses a list of entities to a template based on a view config
protected
parseEntitiesToTemplate(string $blockName, Sigma $template, array<string|int, mixed> $entities, string $viewName) : void
Parameters
- $blockName : string
-
Name of the block to parse for each entity
- $template : Sigma
-
Template to parse
- $entities : array<string|int, mixed>
-
List of entities to parse
- $viewName : string
-
Name of a view specified in Component.yml
parseEntityToTemplate()
Parses an entity to a template based on a view config
protected
parseEntityToTemplate(Sigma $template, EntityBase $entity, string $viewName[, string $prefix = '' ]) : void
Parameters
- $template : Sigma
-
Template to parse
- $entity : EntityBase
-
Entity to parse
- $viewName : string
-
Name of a view specified in Component.yml
- $prefix : string = ''
-
(optional) Allows overriding the prefix set by the view
parseWidget()
Parse a widget
protected
parseWidget(Sigma $template, array<string|int, mixed> &$params, string $name[, string $parent = '' ]) : string|null
Overwrite this instead of parsePage() in order to only parse the
documented widgets.
Parameters
- $template : Sigma
-
Template to parse the widget in
- $params : array<string|int, mixed>
-
Params for the CMD this widget is parsed in
- $name : string
-
Widget identifier to parse
- $parent : string = ''
Tags
Return values
string|null —Value for the rendered widget for custom entity fields
parseWidgets()
Parses all available widget within the given CMD
protected
parseWidgets(Sigma $template, array<string|int, mixed> $params, string $parent[, bool $isWidget = false ]) : void
Parameters
- $template : Sigma
-
Template to parse widgets in
- $params : array<string|int, mixed>
-
Params for the CMD this widget is parsed in
- $parent : string
-
Parent identifier to parse
- $isWidget : bool = false
-
(optional) Whether
$parentis a widget or a cmd. Defaults to cmd.
resolveCmd()
Returns the integration CMD by the requested page CMD
protected
resolveCmd(string $cmd[, array<string|int, mixed> &$params = array() ]) : string
Requested page's CMD may be empty or an alias or parametrized. The return value is the identifier of one of the specified CMDs in Component.yml.
Parameters
- $cmd : string
-
CMD as specified in the requested page
- $params : array<string|int, mixed> = array()
-
(reference) Will be filled by the params (if any)
Tags
Return values
string —One of the CMDs listed in Component.yml
setTypedWidget()
Sets the widget's value in the template
protected
setTypedWidget(Sigma $template, string $name, string $value, string $type) : void
Parameters
- $template : Sigma
-
Template to parse
- $name : string
-
Name of the widget
- $value : string
-
Value for the widget
- $type : string
setWidget()
Sets the widget's value in the template
protected
setWidget(Sigma $template, string $name, string $value) : void
Parameters
- $template : Sigma
-
Template to parse
- $name : string
-
Name of the widget
- $value : string
-
Value for the widget