Documentation

ComponentController extends SystemComponentController
in package

ComponentControlle for DateTime component This component handles timezones and provides methods for conversion

Tags
copyright

Cloudrexx AG

author

Michael Ritter michael.ritter@cloudrexx.com

subpackage

core_datetime

Table of Contents

Properties

$cx  : Cx
Main class instance
$databaseTimezone  : DateTimeZone
$developerDocumentationUrl  : string
URL pointing to the developer documentation for this component
$enduserDocumentationUrl  : string
URL pointing to the end-user documentation for this component
$internalTimezone  : DateTimeZone
$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
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.
createDateTimeForDb()  : DateTime
Returns a \DateTime object in DB timezone
createDateTimeForUser()  : DateTime
Returns a \DateTime object in a user's timezone
db2intern()  : DateTime
Converts a \DateTime object in DB timezone to internal timezone
db2user()  : DateTime
Converts a \DateTime object in DB timezone to a user's timezone
executeCommand()  : void
Execute one of the commands listed in getCommandsForCommandMode()
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.
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.
intern2db()  : DateTime
Converts a \DateTime object in internal timezone to DB timezone
intern2user()  : DateTime
Converts a \DateTime object in internal timezone to a user's timezone
load()  : mixed
Load your component. It is needed for this request.
postComponentLoad()  : mixed
Sets the user's and the database timezone Please note that there's also the user's timezone. Since the user could change (login/logout) during the request, we get it on demand.
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
resolve()  : mixed
Called for additional, component specific resolving
setSystemComponent()  : SystemComponent
Sets the SystemComponent this Controller decorates
strftime()  : string
Localized version of PHP's strftime() function
user2db()  : DateTime
Converts a \DateTime object in a user's timezone to DB timezone
user2intern()  : DateTime
Converts a \DateTime object in user's timezone to internal timezone
adjustFullyQualifiedClassName()  : string
This makes sure a FQCN does not contain double backslashes
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

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.

createDateTimeForDb()

Returns a \DateTime object in DB timezone

public createDateTimeForDb([mixed $time = '' ]) : DateTime
Parameters
$time : mixed = ''
Return values
DateTime

DateTime object in DB timezone

createDateTimeForUser()

Returns a \DateTime object in a user's timezone

public createDateTimeForUser([mixed $time = '' ][, User $user = null ]) : DateTime
Parameters
$time : mixed = ''
$user : User = null

(optional) User object to get timezone of

Return values
DateTime

DateTime object in user's timezone

db2intern()

Converts a \DateTime object in DB timezone to internal timezone

public db2intern(DateTime $datetime) : DateTime
Parameters
$datetime : DateTime

DateTime in database timezone

Return values
DateTime

DateTime in internal timezone

db2user()

Converts a \DateTime object in DB timezone to a user's timezone

public db2user(DateTime $datetime[, User $user = null ]) : DateTime
Parameters
$datetime : DateTime

DateTime in database timezone

$user : User = null

(optional) User object to get timezone of

Return values
DateTime

DateTime in user's timezone

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

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

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

intern2db()

Converts a \DateTime object in internal timezone to DB timezone

public intern2db(DateTime $datetime) : DateTime
Parameters
$datetime : DateTime

DateTime in internal timezone

Return values
DateTime

DateTime in DB timezone

intern2user()

Converts a \DateTime object in internal timezone to a user's timezone

public intern2user(DateTime $datetime[, User $user = null ]) : DateTime
Parameters
$datetime : DateTime

DateTime in internal timezone

$user : User = null

(optional) User object to get timezone of

Return values
DateTime

DateTime in user's timezone

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

Sets the user's and the database timezone Please note that there's also the user's timezone. Since the user could change (login/logout) during the request, we get it on demand.

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

registerEventListeners()

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

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

strftime()

Localized version of PHP's strftime() function

public static strftime(string $format[, int $timestamp = null ][, string $locale = '' ]) : string

See PHP documentation of strftime() for the reference of $format.

Parameters
$format : string

Format according to http://php.net/strftime

$timestamp : int = null

The timestamp to be formatted (optional)

$locale : string = ''

The locale to use instead of the currently loaded locale by the system

Tags
global

array $_CORELANG

todo

Drop argument $locale. As soon as the Locale component does provide the ability to load language files, the argument $locale must be dropped. The Locale component must itself figure out which language files it must load.

todo

Migrate code that loads the language files (InitCMS::loadLangFile()) to use the Locale component as soon as the Locale provides such a method.

Return values
string

Returns a string formatted according format using the given timestamp or the current local time if no timestamp is given. Month and weekday names and other language-dependent strings respect the current set locale.

user2db()

Converts a \DateTime object in a user's timezone to DB timezone

public user2db(DateTime $datetime) : DateTime
Parameters
$datetime : DateTime

DateTime in user's timezone

Return values
DateTime

DateTime in database timezone

user2intern()

Converts a \DateTime object in user's timezone to internal timezone

public user2intern(DateTime $datetime) : DateTime
Parameters
$datetime : DateTime

DateTime in user's timezone

Return values
DateTime

DateTime in internal timezone

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

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