Documentation

ComponentController extends SystemComponentController

Main controller for Cache

Tags
copyright

Cloudrexx AG

author

Cloudrexx Development Team info@cloudrexx.com

subpackage

coremodule_cache

Table of Contents

Properties

$cache  : CacheLib
cache instance (can also be set to \Cx\Core_Modules\Cache\Controller\Cache, check preInit())
$cacheDriver  : mixed
doctrine cache driver instance
$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
$controllers  : array<string|int, mixed>
Available controllers
$systemComponentController  : SystemComponentController
SystemComponentController for this Component

Methods

__call()  : mixed
Route methods like getName(), getType(), getDirectory(), etc.
__construct()  : mixed
Creates new controller
addException()  : mixed
Add an exception that must not get cached
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.
clearCache()  : mixed
Wrapper to flush all cache instances
clearReverseProxyCache()  : mixed
Wrapper to drop a cache page on reverse proxy cache
clearSsiCache()  : mixed
Wrapper to drop all cached ESI/SSI elements
clearSsiCachePage()  : mixed
Wrapper to drop the ESI cache for a specific call
clearUserBasedEsiCache()  : mixed
Clear user based ESI cache
clearUserBasedPageCache()  : mixed
Clear user based page cache
delete()  : mixed
Wrapper to delete an item from cache using the doctrine usercache cache driver
deleteAllFiles()  : mixed
Delete all cached file's of the cache system
deleteComponentFiles()  : mixed
Delete all cached files for a component from cache-folder
deleteNonPagePageCache()  : mixed
Deletes cached header redirects
deleteSingleFile()  : mixed
Deletes a file from page cache
executeCommand()  : void
Execute one of the commands listed in getCommandsForCommandMode()
fetch()  : mixed
Wrapper to fetch an item from cache using the doctrine usercache cachedriver
forceUserbasedPageCache()  : mixed
Forces page cache to be stored per user
getCacheDriver()  : AbstractCache
getCacheFileNameFromUrl()  : string
Gets the local cache file name for an URL
getCacheFileNameSearchPartsFromUrl()  : array<string|int, mixed>
Returns the validated file search parts of the URL
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
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.
getEnduserDocumentationUrl()  : string
Returns the URL pointing to the end-user documentation for this component.
getEsiContent()  : string
Wrapper to return the ESI/SSI content for a (json)data call
getRandomizedEsiContent()  : string
Wrapper to get randomizedEsiContent
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.
internalEsiParsing()  : string
Parses ESI directives internally if configured to do so
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
Ends the contrexx caching after the main template got parsed (frontend only)
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
Start caching with op cache, user cache and cloudrexx caching (cloudrexx caching in frontend only)
preResolve()  : mixed
Do something before resolving is done
registerController()  : null
Registers a controller instance
registerEventListeners()  : mixed
Registers event listeners
registerEvents()  : mixed
Register events
resolve()  : mixed
Called for additional, component specific resolving
save()  : mixed
Wrapper to save an item to cache using the doctrine user usercache cachedriver
setCachedLocaleData()  : mixed
Sets the cached locale data
setCacheDriver()  : mixed
Set the cache driver to use
setCachePrefix()  : mixed
Overwrite the automatically set CachePrefix Setting an empty string will reset the CachePrefix to its initial value.
setSystemComponent()  : SystemComponent
Sets the SystemComponent this Controller decorates
writeCacheFileForRequest()  : mixed
Writes the cache file for the current request
adjustFullyQualifiedClassName()  : string
This makes sure a FQCN does not contain double backslashes
clearCacheCommand()  : mixed
Clears the selected type of cache.
getControllerClassName()  : string
This finds the correct FQCN for a controller name

Properties

$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

$templateDocumentationUrl

URL pointing to the template definitions for this component

protected string $templateDocumentationUrl = ''

Template documentation URL

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

Return values
mixed

Return value of the method to call

addException()

Add an exception that must not get cached

public addException(string|callable $componentOrCallback[, array<string|int, mixed> $additionalInfo = array() ]) : mixed

Case A: $componentOrCallback is a string, $additionalInfo is an empty array Case B: $componentOrCallback is a string, $additionalInfo is non-empty Case C: $componentOrCallback is a callback, $additionalInfo is an empty array Case D: $componentOrCallback is a callback, $additionalInfo is non-empty

Case A will disable caching for all requests to a component. Case B will disable caching for all requests to a component that meet the criteria defined in $additionalInfo. Case C will execute the callback for each not yet cached request. The current Cx instance will be passed to the callback as the first argument. The currently resolved page will be passed to the callback as the second argument. If the callback returns true, the current request will not be cached, otherwise it will. Case D will ignore $additionalInfo and therefore result in case C.

The format for $additionalInfo is either a list of CMDs or a single entry which is a callback. The former will not cache requests to any of the listed CMDs for the component specified in $componentOrCallback. The latter will execute the callback for any request to the component specified in $componentOrCallback. The currently resolved page will be passed to the callback as the first argument. If the callback returns true, the current request will not be cached, otherwise it will.

If there's already an entry for the component specified in $componentOrCallback one of the following will happen:

  • $componentOrCallback is a callback or $additionalInfo is empty: The exception will be blindly added. If at least one of the two (or more) rules match, the request will not get cached.
  • $componentOrCallback is a component name and $additionalInfo is non- empty: If there's a hard-coded entry in $this->exceptions in static::endContrexxCaching() for the given component the exception you're trying to add through this method will get overwritten.
Parameters
$componentOrCallback : string|callable

Component name or callback

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

(optional) Conditions

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
todo

This is currently only available in "frontend" mode.

clearCache()

Wrapper to flush all cache instances

public clearCache([AbstractCache $cacheEngine = null ]) : mixed
Parameters
$cacheEngine : AbstractCache = null

The doctrine cache engine

clearReverseProxyCache()

Wrapper to drop a cache page on reverse proxy cache

public clearReverseProxyCache(mixed $urlPattern) : mixed
Parameters
$urlPattern : mixed

clearSsiCache()

Wrapper to drop all cached ESI/SSI elements

public clearSsiCache([mixed $urlPattern = '' ]) : mixed
Parameters
$urlPattern : mixed = ''

clearSsiCachePage()

Wrapper to drop the ESI cache for a specific call

public clearSsiCachePage(string $adapterName, string $adapterMethod[, array<string|int, mixed> $params = array() ]) : mixed
Parameters
$adapterName : string

(Json)Data adapter name

$adapterMethod : string

(Json)Data method name

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

(optional) params for (Json)Data method call

clearUserBasedEsiCache()

Clear user based ESI cache

public clearUserBasedEsiCache([string $sessionId = '' ]) : mixed

If argument $sessionId is set, then only the cache of the user (identified by sessionid $sessionId) will be flushed. Otherwise (if $sessionId is not set), the complete user based cache is flushed.

Parameters
$sessionId : string = ''

The session ID of the user of whom to clear the esi cache from. If not set, then all used based cach is flusehd.

clearUserBasedPageCache()

Clear user based page cache

public clearUserBasedPageCache([string $sessionId = '' ]) : mixed

If argument $sessionId is set, then only the cache of the user (identified by sessionid $sessionId) will be flushed. Otherwise (if $sessionId is not set), the complete user based cache is flushed.

Parameters
$sessionId : string = ''

The session ID of the user of whom to clear the page cache from. If not set, then all used based cach is flusehd.

delete()

Wrapper to delete an item from cache using the doctrine usercache cache driver

public delete(string $id) : mixed
Parameters
$id : string

Id of the item

deleteAllFiles()

Delete all cached file's of the cache system

public deleteAllFiles([object $cacheEngine = null ]) : mixed
Parameters
$cacheEngine : object = null

The user cache engine

deleteComponentFiles()

Delete all cached files for a component from cache-folder

public deleteComponentFiles(mixed $componentName) : mixed
Parameters
$componentName : mixed

deleteSingleFile()

Deletes a file from page cache

public deleteSingleFile(int $pageId) : mixed
Parameters
$pageId : int

ID of the page to drop cache of

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
see
getCommandsForCommandMode()

fetch()

Wrapper to fetch an item from cache using the doctrine usercache cachedriver

public fetch(string $id) : mixed
Parameters
$id : string

Id of the item

Return values
mixed

The item

getCacheDriver()

public getCacheDriver() : AbstractCache
Return values
AbstractCache

The doctrine cache driver object

getCacheFileNameFromUrl()

Gets the local cache file name for an URL

public getCacheFileNameFromUrl(string $url, string $originalUrl[, bool $withCacheInfoPart = true ]) : string
Parameters
$url : string

URL to get file name for

$originalUrl : string

URL of the page that ESI is parsed for

$withCacheInfoPart : bool = true

(optional) Adds info part (default true)

Return values
string

File name (without path)

getCacheFileNameSearchPartsFromUrl()

Returns the validated file search parts of the URL

public getCacheFileNameSearchPartsFromUrl(mixed $urlPattern, string $originalUrl) : array<string|int, mixed>
Parameters
$urlPattern : mixed
$originalUrl : string

URL of the page that ESI is parsed for

Return values
array<string|int, mixed>

<fileNamePrefix>=><parsedValue> type array

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

getController()

Returns a controller instance if one already exists

public getController( $controllerClass) : Controller
Parameters
$controllerClass :

Short or FQCN controller name

Tags
throws
Exception

if controller exists but cannot be loaded

Return values
Controller

Controller instance

getControllerClasses()

Returns all Controller class names for this component (except this)

public getControllerClasses() : array<string|int, mixed>

Since this comoponent only has this controller, this returns an empty array

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

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

getEsiContent()

Wrapper to return the ESI/SSI content for a (json)data call

public getEsiContent(string $adapterName, string $adapterMethod[, array<string|int, mixed> $params = array() ]) : string
Parameters
$adapterName : string

(Json)Data adapter name

$adapterMethod : string

(Json)Data method name

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

(optional) params for (Json)Data method call

Return values
string

ESI/SSI directives to put into HTML code

getRandomizedEsiContent()

Wrapper to get randomizedEsiContent

public getRandomizedEsiContent(array<string|int, mixed> $esiContentInfos[, int $count = 1 ]) : string

Each entry of $esiContentInfos consists of an array like: array( <adapterName>, <adapterMethod>, , )

Parameters
$esiContentInfos : array<string|int, mixed>

List of ESI content info arrays

$count : int = 1

(optional) Number of unique random entries to parse

Return values
string

ESI randomized include code

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
bool

internalEsiParsing()

Parses ESI directives internally if configured to do so

public internalEsiParsing(string $htmlCode) : string
Parameters
$htmlCode : string

HTML code to replace ESI directives in

Return values
string

Parsed HTML code

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()

Ends the contrexx caching after the main template got parsed (frontend only)

public postFinalize(string &$endcode) : mixed
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()

Start caching with op cache, user cache and cloudrexx caching (cloudrexx caching in frontend only)

public preInit(Cx $cx) : mixed
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

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 ]) : mixed
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)

setCachedLocaleData()

Sets the cached locale data

public setCachedLocaleData(Cx $cx) : mixed

Default locale and the following hashtables are cached: <localeCode> to <localeId> <localeCountryCode> to <localeCodes>

Parameters
$cx : Cx

Cx instance

setCacheDriver()

Set the cache driver to use

public setCacheDriver( $driver) : mixed
Parameters
$driver :

\Doctrine\Common\Cache\AbstractCache The doctrine cache driver object

setCachePrefix()

Overwrite the automatically set CachePrefix Setting an empty string will reset the CachePrefix to its initial value.

public setCachePrefix([ $prefix = '' ]) : mixed
Parameters
$prefix : = ''

String The new CachePrefix to be used

writeCacheFileForRequest()

Writes the cache file for the current request

public writeCacheFileForRequest(Page $page, array<string|int, mixed> $headers, string $endcode) : mixed
Parameters
$page : Page

Current page (might be null for redirects before postResolve)

$headers : array<string|int, mixed>

List of headers set for the current response

$endcode : string

Current response

adjustFullyQualifiedClassName()

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

clearCacheCommand()

Clears the selected type of cache.

protected clearCacheCommand(string $type[, string $options = '' ]) : mixed

Known cache types are:

  • user: DB cache
  • page: "Contrexx cache"
  • esi: ESI/SSI cache (internal or on proxy)
  • proxy: Reverse proxy cache
  • opcode: PHP OP code cache
  • all: Drop all of the above
Parameters
$type : string

Cache type to clear

$options : string = ''

(optional) Engine for user or opcode cache, filter for page, esi and reverse proxy cache

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


        
On this page

Search results