Child pages
  • cRegistry
Skip to end of metadata
Go to start of metadata

Access point / Container for global data

CONTENIDO used to use a huge amount of global variables. This, for sure, is not the best approach of handling data that has to be generally available in every corner of the code. As PHP is going to banish these beloved variables in a future version, we had to develop another solution. This brought us to the idea to build a registry holding all this data. In order to allow a smooth migration the registry already offers an easy read access to this data although the data itself is still global. This will change in a future version of CONTENIDO.

The registries heart is the protected method _fetchGlobalVariable() which provides access to global data and allows to define a default value if the requested data does not exist. All other getters are build ontop of this method. A rough overview of the data that can be accessed through the registry:

editisBackendEditModedefault false
langgetLanguageIddefault load_lang
clientgetClientIddefault load_client
idartgetArticleIddefault 0
idartlanggetArticleLanguageIddefault 0
idcatgetCategoryIddefault 0
idcatlanggetCategoryLanguageIddefault 0
idcatartgetCategoryArticleIddefault 0
cCurrentModulegetCurrentModuleIddefault 0; This function will work only within module code.
cCurrentContainergetCurrentContainerIddefault 0; This function will work only within module code.
cfggetConfigdefault array()
cfgClientgetClientConfigdefault array(); can take a parameter $clientId in order to return config of this client

Convenience methods

Furthermore the registry is flavoured with some convenience methods to ease the development of modules and plugins.

getLanguageReturns an instance of class cApiLanguage with the ID that is returned by getLanguageId.
getClientReturns an instance of class cApiClient with the ID that is returned by getClientId.
getArticleReturns an instance of class cApiArticle with the ID that is returned by getArticleId.
getArticleLanguageReturns an instance of class cApiArticleLanguage with the ID that is returned by getArticleLanguageId.
getCategoryReturns an instance of class cApiCategory with the ID that is returned by getCategoryId.
getCategoryLanguageReturns an instance of class cApiCategoryLanguage with the ID that is returned by getCategoryLanguageId.
getCategoryArticleReturns an instance of class cApiCategoryArticle with the ID that is returned by getCategoryArticleId.
bootstrapBootstraps the CONTENIDO framework and initializes the global variables sess, auth and perm.
shutdownShutdowns the CONTENIDO framework on page close.
addInfoMessageStores an information massage in the cRegistry.
getInfoMessagesReturns an array with information messages.
addErrorMessageStores an error massage in the cRegistry.
getErrorMessagesReturns an array with error messages.
addWarningMessageStores an warning massage in the cRegistry.
getWarningMessagesReturns an array with warning messages.
isTrackingAllowedwhether tracking is allowed by the DNT header