ComponentController
extends SystemComponentController
in package
Usercache handling
Use the methods fetch(), save() and delete() to interact.
Tags
Table of Contents
Properties
- $config : array<string|int, mixed>
- Config loaded from YAML
- $cx : Cx
- Main class instance
- $developerDocumentationUrl : string
- URL pointing to the developer documentation for this component
- $enduserDocumentationUrl : string
- URL pointing to the end-user documentation for this component
- $systemComponent : SystemComponent
- Decorated SystemComponent
- $templateDocumentationUrl : string
- URL pointing to the template definitions for this component
- $usercache : Usercache
Methods
- __call() : mixed
- Decoration: all methods that are not specified in this or child classes call the corresponding method of the decorated SystemComponent
- __construct() : mixed
- Initializes a controller
- adjustResponse() : mixed
- Do something with a Response object You may do page alterations here (like changing the metatitle) You may do response alterations here (like set headers) PLEASE MAKE SURE THIS METHOD IS MOCKABLE. IT MAY ONLY INTERACT WITH resolve() HOOK.
- clear() : void
- Clears all Memcacheddata related to this Domain if Memcached is installed
- deactivateUserCacheForCurrentRequest() : void
- Deactivates Doctrine cache for this request
- delete() : void
- Wrapper to delete an item from cache using the doctrine usercache cache driver
- executeCommand() : void
- Execute one of the commands listed in getCommandsForCommandMode()
- fetch() : mixed
- Wrapper to fetch an item from cache using the doctrine usercache cachedriver
- getCommandDescription() : string
- Returns the description for a command provided by this component
- getCommandsForCommandMode() : array<string|int, mixed>
- Returns a list of command mode commands provided by this component
- getComponent() : SystemComponentController
- Get component controller object
- getConfiguration() : array<string|int, mixed>
- Returns the usercache configuration
- getConfigValue() : string
- Returns a value from the config tree
- getConfigValues() : array<string|int, mixed>
- Returns part of the config tree
- getController() : Controller
- Returns a controller instance if one already exists
- getControllerClasses() : array<string|int, mixed>
- Returns all Controller class names for this component (except this)
- getControllers() : array<string|int, mixed>
- Returns a list of controllers
- getControllersAccessableByJson() : array<string|int, mixed>
- Returns a list of JsonAdapter class names
- getDeveloperDocumentationUrl() : string
- Returns the URL pointing to the developer documentation of this component.
- getDoctrineCacheDriver() : CacheProvider
- Detects the correct doctrine cache driver for the user caching engine in use
- getEnduserDocumentationUrl() : string
- Returns the URL pointing to the end-user documentation for this component.
- getSystemComponent() : SystemComponent
- Returns the SystemComponent this Controller decorates
- getSystemComponentController() : SystemComponentController
- Returns the main controller
- getTemplateDocumentationUrl() : string
- Returns the URL pointing to the template documentation for this component.
- hasAccessToExecuteCommand() : bool
- Check whether the command has access to execute or not.
- isActive() : bool
- Whether user cache is active
- isValidConfiguration() : bool
- Tells whether a server is reachable with the current config
- load() : mixed
- Load your component. It is needed for this request.
- postComponentLoad() : mixed
- Do something after all active components are loaded USE CAREFULLY, DO NOT DO ANYTHING COSTLY HERE! CALCULATE YOUR STUFF AS LATE AS POSSIBLE.
- postContentLoad() : mixed
- Do something after content is loaded from DB
- postContentParse() : mixed
- Do something after a module is loaded
- postFinalize() : mixed
- Do something after main template got parsed
- postInit() : mixed
- Do something after system initialization
- postResolve() : mixed
- Do something after resolving is done
- preComponentLoad() : mixed
- Do something before component load * USE CAREFULLY, DO NOT DO ANYTHING COSTLY HERE! CALCULATE YOUR STUFF AS LATE AS POSSIBLE.
- preContentLoad() : mixed
- Do something before content is loaded from DB
- preContentParse() : mixed
- Do something before a module is loaded
- preFinalize() : mixed
- Do something before main template gets parsed
- preInit() : mixed
- Do something before system initialization
- preResolve() : mixed
- Do something before resolving is done
- registerController() : null
- Registers a controller instance
- registerEventListeners() : mixed
- Register your event listeners here
- registerEvents() : mixed
- Register your events here
- reInit() : void
- Re-initializes the usercache
- resolve() : mixed
- Called for additional, component specific resolving
- save() : void
- Wrapper to save an item to cache using the doctrine user usercache cachedriver
- setSystemComponent() : SystemComponent
- Sets the SystemComponent this Controller decorates
- adjustFullyQualifiedClassName() : string
- This makes sure a FQCN does not contain double backslashes
- getControllerClassName() : string
- This finds the correct FQCN for a controller name
- loadConfigFile() : array<string|int, mixed>
- Loads a config YAML file
- loadData() : void
- Load data from Component.yml
Properties
$config
Config loaded from YAML
protected
array<string|int, mixed>
$config
= array()
Tree of configs
$cx
Main class instance
protected
Cx
$cx
= null
$developerDocumentationUrl
URL pointing to the developer documentation for this component
protected
string
$developerDocumentationUrl
= ''
Developer documentation URL
$enduserDocumentationUrl
URL pointing to the end-user documentation for this component
protected
string
$enduserDocumentationUrl
= ''
End-user documentation URL
$systemComponent
Decorated SystemComponent
protected
SystemComponent
$systemComponent
$templateDocumentationUrl
URL pointing to the template definitions for this component
protected
string
$templateDocumentationUrl
= ''
Template documentation URL
$usercache
protected
Usercache
$usercache
Usercache instance
Methods
__call()
Decoration: all methods that are not specified in this or child classes call the corresponding method of the decorated SystemComponent
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()
Initializes a controller
public
__construct(SystemComponent $systemComponent, Cx $cx) : mixed
Parameters
- $systemComponent : SystemComponent
-
SystemComponent to decorate
- $cx : Cx
-
The Cloudrexx main class
Tags
adjustResponse()
Do something with a Response object You may do page alterations here (like changing the metatitle) You may do response alterations here (like set headers) PLEASE MAKE SURE THIS METHOD IS MOCKABLE. IT MAY ONLY INTERACT WITH resolve() HOOK.
public
adjustResponse(Response $response) : mixed
Parameters
- $response : Response
-
Response object to adjust
Tags
clear()
Clears all Memcacheddata related to this Domain if Memcached is installed
public
clear() : void
deactivateUserCacheForCurrentRequest()
Deactivates Doctrine cache for this request
public
deactivateUserCacheForCurrentRequest() : void
Please note that components that directly use the underlying usercache (like ClassLoader and DataSet) do still use usercache after this.
delete()
Wrapper to delete an item from cache using the doctrine usercache cache driver
public
delete(string $id[, bool $fromCodebase = false ]) : void
Parameters
- $id : string
-
Id of the item
- $fromCodebase : bool = false
-
Defaults to false. If set to true data is deleted from codebase-wide cache
executeCommand()
Execute one of the commands listed in getCommandsForCommandMode()
public
executeCommand(string $command, array<string|int, mixed> $arguments[, array<string|int, mixed> $dataArguments = array() ]) : void
Parameters
- $command : string
-
Name of command to execute
- $arguments : array<string|int, mixed>
-
List of arguments for the command
- $dataArguments : array<string|int, mixed> = array()
-
(optional) List of data arguments for the command
Tags
fetch()
Wrapper to fetch an item from cache using the doctrine usercache cachedriver
public
fetch(string $id[, bool $fromCodebase = false ]) : mixed
Parameters
- $id : string
-
Id of the item
- $fromCodebase : bool = false
-
Defaults to false. If set to true fetch is from codebase-wide cache
Return values
mixed —The item
getCommandDescription()
Returns the description for a command provided by this component
public
getCommandDescription(string $command[, bool $short = false ]) : string
Parameters
- $command : string
-
The name of the command to fetch the description from
- $short : bool = false
-
Wheter to return short or long description
Return values
string —Command description
getCommandsForCommandMode()
Returns a list of command mode commands provided by this component
public
getCommandsForCommandMode() : array<string|int, mixed>
Return values
array<string|int, mixed> —List of command names
getComponent()
Get component controller object
public
getComponent(string $name) : SystemComponentController
Parameters
- $name : string
-
component name
Return values
SystemComponentController —The requested component controller or null if no such component exists
getConfiguration()
Returns the usercache configuration
public
getConfiguration() : array<string|int, mixed>
Return values
array<string|int, mixed> —Array with keys "ip" and "port"
getConfigValue()
Returns a value from the config tree
public
getConfigValue(string $key) : string
Parameters
- $key : string
-
Slash-separated path to requested branch
Tags
Return values
string —Requested value as string
getConfigValues()
Returns part of the config tree
public
getConfigValues(string $key) : array<string|int, mixed>
Parameters
- $key : string
-
Slash-separated path to requested branch
Tags
Return values
array<string|int, mixed> —Requested values
getController()
Returns a controller instance if one already exists
public
getController(mixed $controllerClass) : Controller
Parameters
- $controllerClass : mixed
-
Short or FQCN controller name
Tags
Return values
Controller —Controller instance
getControllerClasses()
Returns all Controller class names for this component (except this)
public
getControllerClasses() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —List of Controller class names (without namespace)
getControllers()
Returns a list of controllers
public
getControllers([bool $loadedOnly = true ]) : array<string|int, mixed>
Parameters
- $loadedOnly : bool = true
-
(optional) If false, controller that did not register are instanciated, default true
Return values
array<string|int, mixed> —List of Controller instances
getControllersAccessableByJson()
Returns a list of JsonAdapter class names
public
getControllersAccessableByJson() : array<string|int, mixed>
The array values might be a class name without namespace. In that case the namespace \Cx{component_type}{component_name}\Controller is used. If the array value starts with a backslash, no namespace is added.
Avoid calculation of anything, just return an array!
Return values
array<string|int, mixed> —List of ComponentController classes
getDeveloperDocumentationUrl()
Returns the URL pointing to the developer documentation of this component.
public
getDeveloperDocumentationUrl() : string
Return values
string —URL pointing to the developer documentation
getDoctrineCacheDriver()
Detects the correct doctrine cache driver for the user caching engine in use
public
getDoctrineCacheDriver([bool $forMetaData = false ]) : CacheProvider
Parameters
- $forMetaData : bool = false
-
Set to true to fetch the cache driver to be used for meta data caching.
Return values
CacheProvider —The doctrine cache driver object
getEnduserDocumentationUrl()
Returns the URL pointing to the end-user documentation for this component.
public
getEnduserDocumentationUrl() : string
Return values
string —URL pointing to the end-user documentation or empty string
getSystemComponent()
Returns the SystemComponent this Controller decorates
public
getSystemComponent() : SystemComponent
Return values
SystemComponentgetSystemComponentController()
Returns the main controller
public
getSystemComponentController() : SystemComponentController
Return values
SystemComponentController —Main controller for this system component
getTemplateDocumentationUrl()
Returns the URL pointing to the template documentation for this component.
public
getTemplateDocumentationUrl() : string
Return values
string —URL pointing to the template documentation or empty string
hasAccessToExecuteCommand()
Check whether the command has access to execute or not.
public
hasAccessToExecuteCommand(string $command, array<string|int, mixed> $arguments) : bool
Parameters
- $command : string
-
name of the command to execute
- $arguments : array<string|int, mixed>
-
list of arguments for the command
Return values
boolisActive()
Whether user cache is active
public
isActive() : bool
Return values
bool —True if usercache is active, false otherwise
isValidConfiguration()
Tells whether a server is reachable with the current config
public
isValidConfiguration() : bool
Return values
bool —True if server can be reached, false otherwise
load()
Load your component. It is needed for this request.
public
load(Page $page) : mixed
This loads your FrontendController or BackendController depending on the mode Cx runs in. For modes other than frontend and backend, nothing is done. If you you'd like to name your Controllers differently, or have another use case, overwrite this.
Parameters
- $page : Page
-
The resolved page
postComponentLoad()
Do something after all active components are loaded USE CAREFULLY, DO NOT DO ANYTHING COSTLY HERE! CALCULATE YOUR STUFF AS LATE AS POSSIBLE.
public
postComponentLoad() : mixed
postContentLoad()
Do something after content is loaded from DB
public
postContentLoad(Page $page) : mixed
USE CAREFULLY, DO NOT DO ANYTHING COSTLY HERE! CALCULATE YOUR STUFF AS LATE AS POSSIBLE
Parameters
- $page : Page
-
The resolved page
postContentParse()
Do something after a module is loaded
public
postContentParse(Page $page) : mixed
This method is called only if any module gets loaded for content parsing USE CAREFULLY, DO NOT DO ANYTHING COSTLY HERE! CALCULATE YOUR STUFF AS LATE AS POSSIBLE
Parameters
- $page : Page
-
The resolved page
postFinalize()
Do something after main template got parsed
public
postFinalize(string &$endcode) : mixed
USE CAREFULLY, DO NOT DO ANYTHING COSTLY HERE!
Parameters
- $endcode : string
-
The processed data to be sent to the client as response
postInit()
Do something after system initialization
public
postInit(Cx $cx) : mixed
USE CAREFULLY, DO NOT DO ANYTHING COSTLY HERE! CALCULATE YOUR STUFF AS LATE AS POSSIBLE. This event must be registered in the postInit-Hook definition file config/postInitHooks.yml.
Parameters
- $cx : Cx
-
The instance of \Cx\Core\Core\Controller\Cx
postResolve()
Do something after resolving is done
public
postResolve(Page $page) : mixed
USE CAREFULLY, DO NOT DO ANYTHING COSTLY HERE! CALCULATE YOUR STUFF AS LATE AS POSSIBLE
Parameters
- $page : Page
-
The resolved page
preComponentLoad()
Do something before component load * USE CAREFULLY, DO NOT DO ANYTHING COSTLY HERE! CALCULATE YOUR STUFF AS LATE AS POSSIBLE.
public
preComponentLoad() : mixed
This event must be registered in the preComponentLoad-Hook definition file config/preComponentLoadHooks.yml.
preContentLoad()
Do something before content is loaded from DB
public
preContentLoad(Page $page) : mixed
USE CAREFULLY, DO NOT DO ANYTHING COSTLY HERE! CALCULATE YOUR STUFF AS LATE AS POSSIBLE
Parameters
- $page : Page
-
The resolved page
preContentParse()
Do something before a module is loaded
public
preContentParse(Page $page) : mixed
This method is called only if any module gets loaded for content parsing USE CAREFULLY, DO NOT DO ANYTHING COSTLY HERE! CALCULATE YOUR STUFF AS LATE AS POSSIBLE
Parameters
- $page : Page
-
The resolved page
preFinalize()
Do something before main template gets parsed
public
preFinalize(Sigma $template) : mixed
USE CAREFULLY, DO NOT DO ANYTHING COSTLY HERE! CALCULATE YOUR STUFF AS LATE AS POSSIBLE
Parameters
- $template : Sigma
-
The main template
preInit()
Do something before system initialization
public
preInit(Cx $cx) : mixed
USE CAREFULLY, DO NOT DO ANYTHING COSTLY HERE! CALCULATE YOUR STUFF AS LATE AS POSSIBLE. This event must be registered in the preInit-Hook definition file config/preInitHooks.yml.
Parameters
- $cx : Cx
-
The instance of \Cx\Core\Core\Controller\Cx
preResolve()
Do something before resolving is done
public
preResolve(Url $request) : mixed
USE CAREFULLY, DO NOT DO ANYTHING COSTLY HERE! CALCULATE YOUR STUFF AS LATE AS POSSIBLE
Parameters
- $request : Url
-
The URL object for this request
registerController()
Registers a controller instance
public
registerController(Controller $controller) : null
Parameters
- $controller : Controller
-
Controller to register
Return values
nullregisterEventListeners()
Register your event listeners here
public
registerEventListeners() : mixed
USE CAREFULLY, DO NOT DO ANYTHING COSTLY HERE! CALCULATE YOUR STUFF AS LATE AS POSSIBLE. Keep in mind, that you can also register your events later. Do not do anything else here than initializing your event listeners and list statements like $this->cx->getEvents()->addEventListener($eventName, $listener);
registerEvents()
Register your events here
public
registerEvents() : mixed
Do not do anything else here than list statements like $this->cx->getEvents()->addEvent($eventName);
reInit()
Re-initializes the usercache
public
reInit() : void
This is used to apply the new config if the config was changed.
resolve()
Called for additional, component specific resolving
public
resolve(array<string|int, mixed> $parts, Page $page) : mixed
If /en/Path/to/Page is the path to a page for this component a request like /en/Path/to/Page/with/some/parameters will give an array like array('with', 'some', 'parameters') for $parts PLEASE MAKE SURE THIS METHOD IS MOCKABLE. IT MAY ONLY INTERACT WITH adjustResponse() HOOK.
This may be used to redirect to another page
Parameters
- $parts : array<string|int, mixed>
-
List of additional path parts
- $page : Page
-
Resolved virtual page
save()
Wrapper to save an item to cache using the doctrine user usercache cachedriver
public
save(string $id, mixed $data[, int $lifeTime = 0 ][, bool $fromCodebase = false ]) : void
Parameters
- $id : string
-
Id of the item
- $data : mixed
-
data of the item
- $lifeTime : int = 0
-
Expiraton time of the item (if it equals zero, the item never expires)
- $fromCodebase : bool = false
-
Defaults to false. If set to true data is saved to codebase-wide cache
setSystemComponent()
Sets the SystemComponent this Controller decorates
public
setSystemComponent(mixed $systemComponent) : SystemComponent
Parameters
- $systemComponent : mixed
Return values
SystemComponentadjustFullyQualifiedClassName()
This makes sure a FQCN does not contain double backslashes
protected
adjustFullyQualifiedClassName(string $className) : string
Parameters
- $className : string
-
FQCN of a controller
Return values
string —Clean FQCN of a controller
getControllerClassName()
This finds the correct FQCN for a controller name
protected
getControllerClassName(string $controllerClassShort) : string
Parameters
- $controllerClassShort : string
-
Short name for controller
Return values
string —Fully qualified controller class name
loadConfigFile()
Loads a config YAML file
protected
loadConfigFile(string $filename) : array<string|int, mixed>
Parameters
- $filename : string
-
Name of the file to load
Tags
Return values
array<string|int, mixed> —Loaded data
loadData()
Load data from Component.yml
protected
loadData() : void